Hi everyone i'm trying to format my invoice word doc to not show repeated items entries. Is it possible to do with a if expression inside the document? Something like a Unique() expression.
Solved! Go to Solution.
Don't iterate across the child records, iterate across a table of items.
Consider these 3 tables:
Order:
id |
a |
Order_Item
id | order_id | item_id | qty |
1 | a | ddd | 5 |
2 | a | fff | 7 |
Item
id | name |
aaa | ... |
ddd | ... |
ggg | ... |
fff | ... |
Then your template would be like this:
<<START: UNIQUE([related...][item_id])>>
NAME: <<[item_id].[name]>>
Total QTY: <<SUM(SELECT(order_item[qty] , AND( [order]=[_THISROW] , [item_id]=[_THISROW-1] ) ) )>>
<<END>>
Need more info. Are you using a START expression?
Sorry for late response, I will try to clarify my full problem.
I'm trying to make a restaurant invoice app, I successfully make it and it can also output a pdf, but then I find out that if I make two inputs of the same item, it outputs, as well, two different lines for each item, I searched online and I find a solution which creates a unique value by concatenating the [ItemName] and [Invoice_No] and then summing the [qty] with rows that include this unique value to generate a value for the item and the same goes for the price, but it does not solve my initial problem that is: in the template I get two lines for the same item, like this.
What i want is that only one petit gateau shows, now my pdf looks like this
it is stretched because it's for a invoice printer, transcribing it goes like that:
<<Start:[Related ComandaDets]>><<[Repeat Items Qty]>> | <<[Item_Name]>> | <<[Unity_Price]>> | <<[Repeat Items Price]>><<End>> |
Don't iterate across the child records, iterate across a table of items.
Consider these 3 tables:
Order:
id |
a |
Order_Item
id | order_id | item_id | qty |
1 | a | ddd | 5 |
2 | a | fff | 7 |
Item
id | name |
aaa | ... |
ddd | ... |
ggg | ... |
fff | ... |
Then your template would be like this:
<<START: UNIQUE([related...][item_id])>>
NAME: <<[item_id].[name]>>
Total QTY: <<SUM(SELECT(order_item[qty] , AND( [order]=[_THISROW] , [item_id]=[_THISROW-1] ) ) )>>
<<END>>
Thanks Marc,
It was very clarifying, for some reason I thought that I was locked to the table that the automation was designed to work with, for that reason I was struggling with this. Thank you for your time.
User | Count |
---|---|
18 | |
9 | |
8 | |
5 | |
5 |