My tables are structured as follows: Order (Parent) > Daysheet (child) > Materials Used (Grandchild)
A Daysheet may have related Materials Used of the same product entered multiple times and the same Materials Used may also be linked to numerous Day Sheets.
When an Order is closed I need to send an email that can be used for data entry into an accounting system so it needs to show a sum of Materials Used from all the related Day Sheets and I am not sure how to do that.
At present I am using the following expression but it only gives me a list of all the related Materials Used, often with duplicates, but I donโt know how to group and Sum them by Materials Used. Any suggestions?
<<Start: SELECT(MaterialsUsed[MaterialUsedKey],IN([MaterialUsedKey],[_THISROW].[MaterialsUsed]))>><<[Qty]>>
Solved! Go to Solution.
Good. You should be able to do this then:
First, weโll enter a START expression that will iterate across all unique Materials in the entire Order.
<<START:
UNIQUE(
SELECT(
MaterialsUsed[Material*] ,
[Daysheet*].[Order*] = [_THISROW-1]
)
)
>>
Replace the starred columns if they are different in your app. The โ[_THISROW-1]โ might be wrong.
From there, we can get sums for each particular Material:
SUM(
SELECT(
MaterialsUsed[quantity*] ,
AND(
[Daysheet*].[Order*] = [_THISROW-2] ,
[Material] = [_THISROW-1].[Material-key*]
)
)
)
Again, replace starred column names where appropriate, and the "[_THISROW-n]"s may need adjusted.
User | Count |
---|---|
43 | |
27 | |
24 | |
22 | |
13 |