Line wrapping with white space padding using stringtemplate - stringtemplate

How can I pad a sentence with white space so that it is printed in a 'block'.
I want to print a receipt. for a given item I want to print the quantity, item name, and price.
12 x Example short name £2.00
1 x This is an example of
a long name £10.00
The 'block' to which I refer to is shown below.
12 x |Example short name | £2.00
1 x |This is an example of |
|a long name | £10.00
Using the example above I can easily handle the formatting of the quantity and the price. Using string formatting. Then for the item name the best method to use, I think, is to split the item name in code, and use the wrap functionality of StringTemplate, but I don't know how to pad the remainder of the line with whitespace
I am using .Net and StringTemplate 4. Here is a simplified version of the template I have. Assuming I have an item with the properties Quantity, ItemName (split into an array of strings), and Price.
<item.Quantity; format="{0,4}"> x <item.ItemName; wrap, separator=" ", anchor><item.Price; format="£{0,8}">
Now at the moment the only way I can think to get it to work is to calculate the white space in code and add it to the item name array.
So is there a neat way to do it in StringTemplate?

Related

CR | Copy data to another row using a formula field or variable

Here is my problem:
Raw data 1
If there is a position 105 and 150, I need the material number of position 150. If there is only position 105, I need the material number of position 105.
On the right side of the picture you can see the correct selected material number.
Now I need to assign this data to position 100 (bc I will use a counter later on, which is depending on position 100).
Here you can see more of the raw data of the report (I can´t insert the complete report here, I use the details area only for testing).
I marked one "group" in which you can see why I can´t change the order of the positions. In this case I need to use position 105 to output the material number (number rightmost on the red border) because there is no position 150.
Raw data 2
Here is another example with position 150 used for the material number (the correct material number will be placed on position 105 every time):
Raw data 3
To use this material number in my following tables, it need to be assigned to position 100.
Thanks!

Power BI - Is there a way to conditionally format a text column if it does NOT meet a criteria?

as the title states, is there a way to conditionally format a text column if it does NOT meet a criteria - In Power BI?
i.e: Format a column's font colour if it is NOT "x".
e.g:
I want to format the following data (using the letter column) and highlight a, b and c (as they are not equal to x)
ID | code | letter
------------------
1 | 123 | a
2 | 345 | b
3 | 567 | x
4 | 789 | c
------------------
You can always create a measure to determine the desired highlight color for example, and use it, e.g. like this:
Measure = If(FIRSTNONBLANK('Table'[letter]; [letter]) = "x"; BLANK(); "#AABBCC")
See Color formatting by field value:
You can use a measure or a column that specifics a color, either using a text value or a hex code, to apply that color to the background of font color of a table or matrix visual. You can also create custom logic for a given field, and have that logic apply the desired color to the font or background.
You didn't mention what do you want to highlight and how. If the data will not be aggregated and show all rows in a table, you can calculate the highlighting color in conditional column in Power Query Editor, or computed column (DAX). If the highlighting rules will be applied on aggregated data, then you should use DAX measure.
If you want to highlight a cell, return the desired color. Otherwise return null in Power Query Editor, or BLANK() in DAX.

Access graph get series on 2 database fields

I have a technical issue with access graphs: I have a table in Access database with 4 fields: xValue, yValue, round, partOfRound
What I want: there are always 2 rounds, each round has 2 parts. I need to get a series per round per part (so from round 1 part 1, round 1 part 2, round 2 part 1, round 2 part 2) with all xValues and yValues in a chart.
But then I have an other problem:The xValue isn't a good number to show, this is needing to be this number divided by a number from an other table (see this as number in table3) where the row of table 3 equels the identifier with the identifier I use for my chart. (IDtable2=IDtable3)
The final result will be 4 lines with the data in my graph, so 4 series.
But when I use the wizard for making graphs, I can only set 1 field to the series value, so it will see a round as just 1 series instead of 2.
How do I solve this problem?
Kind regards
Kristof
What type of graph - just a column?
Concatenate the round and partOfRound fields.
Try changing the graph RowSource to:
TRANSFORM Sum(Table2.yValue) AS SumOfyValue SELECT Table2.xValue FROM Table2 GROUP BY Table2.xValue PIVOT [round] & "_" & [partOfRound];
Possible SQL to include table join to calculate the division:
TRANSFORM Sum(Table2.yValue) AS SumOfyValue
SELECT Round([xValue]/[Factor],0) AS x
FROM Table3 INNER JOIN Table2 ON Table3.PK_Table3 = Table2.FK_Table3
GROUP BY Round([xValue]/[Factor],0)
PIVOT [round] & "_" & [partOfRound];
For both queries, I had to open the graph editor (double click the graph) and from the menu click on "By Column" button to get the x values on the x axis.
I do hope round is not an actual name as it is a reserved word and should not use reserved words as names for anything.

Determining What Line Does in Awk

I'm a very new beginner to awk. I'm reading over a simple loop statement where by using the split() command I have defined the 'a' array before the beginning of the loop and the 'b' array in each iteration of the loop.
Can someone help me with the statement below? I put it in to perspective since I know what the splits and for loop are doing.
split($2,a,":");
for(i=1,i<length(a),i++){
split(a[i],b," ")
#I don't know what the statement below this line does.
#It appears to be creating a multidimensional thing?
x[b[1]]=b[2]
It looks like a single dimension array. Let's say if you had a text file with one line like this:
1|age 10:fname john:lname smith|12345
Assuming a delimiter of pipe symbol |, your $2 is going to be age 10:fname john:lname smith.
Split that by colon : will give 3 items: age 10, fname john and lname smith
for loops through these 3 items. It takes the first item age 10
It is split that up by space. b[1] is now age, b[2] is now 10
Array x['age'] is set to 10
Similarly, x['lname'] is set to smith and x['fname'] is set to 'john'
x[b[1]]=b[2]
It's not creating a multidementional array.
x is a array. it's assigning the value of array key b[z] to b[z]. z is a positive integer I just used here.

Highlighting Values in a Crystal Reports Crosstab based on sibling values

I have crosstab which has row columns indicating different classes, and then peoples names across the top.
| | Required | Person 1 | Person 2 | Person 3 |
| Class 1 | 8 6 | 1 6 | 3 6 | 4 6 |
| Class 2 | 6 2 | 3 2 | 2 2 | 1 2 |
Each field contains 2 values The first value is the number of hours spent in the class, the second field is the number of hours required for certification.
The Required field id my grand total summary.
In the cross tab expert the fields are defined as follows.
Rows:
Command.descr -> a field containing the class names
Columns:
Command.fullname -> a field containing students full names
Summarized Fields:
Sum of Command.evlength -> summation of all time spent in a given course
Max of #required -> this formula returns the number of required hours based on the course name
I am trying to highlight the field Sum of Command.evlength if it is greater than or equal to the value of Max of #required.
My solution was to perform background formatting. Right-Click on the Sum of Command.evlength field, select Format Field. Click the borders tab, check Background, and enter a formula.
The formula I was using is:
if CurrentFieldValue >= {#required} then color(152, 251, 152) else crNoColor
This is not the correct formula. My crosstab has been placed in the footer, which causes {#required} to contain the last value in the grid which in the above example is 2.
From my research I thought I would have to use GridRowColumnValue(row or column name) to access the value of {#required} in the crosstab, but I could not come up with the correct string to represent it.
Does anyone have a way for me to correctly perform this comparison?
Frustratingly I don't think you can use the highlighting expert to compare to a dynamic value. You could swap the columns round then add the following formulas:
To the max_of_required background colour:
whileprintingrecords;
global numbervar required_hrs := currentfieldvalue;
crNoColor;
To the sum_of_command.evlength background colour:
whileprintingrecords;
global numbervar required_hrs;
if currentfieldvalue >= required_hrs then
crRed
else
crNoColor;
I think there are a few other ways but i'm not as confident with those so start here.