Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi!
I have this kind of data structure
OrderHeader | OrderItem | Amount |
A | 1 | 100 |
A | 2 | 200 |
B | 5 | 200 |
A | 3 | 800 |
C | 4 | 1005 |
Now I need a DAX measure that only sums the Amount of the OrderItem when the sum of the header is bigger or equal then 1000. My idea was to first write a measure that always sums the amount for the header and then use it for filtering in another measure. But unfortunetly it did not work as intended. It basically filtered when the item was smaller then the threshold (1000) not the sum of the header level.
How do I fix the first measure that it always, not depending on the context of the table, calculates the sum on the header level and checks if it is bigger then the threshold?
One example how it should be shown later
OrderItem | Amount |
1 | 100 |
2 | 200 |
3 | 800 |
4 | 1005 |
Solved! Go to Solution.
Hi @Penguin12 ,
In this case, to reuse this logic in multiple measures in a performatic way, my suggestion is to create a calculated column in the original table to have the total for each header. For this you can use the same logic in the previous reply:
NewColumn =
CALCULATE (
SUM ( 'Table'[Amount] ),
ALLEXCEPT ( 'Table', 'Table'[OrderHeader] )
)
Then you can use this column to filter as needed using CALCULATE/FILTER.
Otherwise, just use the variable below in each measure to calculate the table on the fly (the is no problem with this approach).
VAR _Table_Total_Header =
ADDCOLUMNS (
'Table',
"Header_Total",
CALCULATE (
SUM ( 'Table'[Amount] ),
ALLEXCEPT ( 'Table', 'Table'[OrderHeader] )
)
)
Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!
Best regards,
Joao Ribeiro
@joaoribeiro thank you very much for reply! But is there a way to rather have it in two measures so I can use the second one for example in different contexts in tables instead of creating a new table? I have been struggeling with this and was not able to rewrite it
Hi @Penguin12 ,
In this case, to reuse this logic in multiple measures in a performatic way, my suggestion is to create a calculated column in the original table to have the total for each header. For this you can use the same logic in the previous reply:
NewColumn =
CALCULATE (
SUM ( 'Table'[Amount] ),
ALLEXCEPT ( 'Table', 'Table'[OrderHeader] )
)
Then you can use this column to filter as needed using CALCULATE/FILTER.
Otherwise, just use the variable below in each measure to calculate the table on the fly (the is no problem with this approach).
VAR _Table_Total_Header =
ADDCOLUMNS (
'Table',
"Header_Total",
CALCULATE (
SUM ( 'Table'[Amount] ),
ALLEXCEPT ( 'Table', 'Table'[OrderHeader] )
)
)
Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!
Best regards,
Joao Ribeiro
Hi @Penguin12 ,
I think you use the following measure structure to solve your problem:
VAR _Table_Total_Header =
ADDCOLUMNS (
'Table',
"Header_Total",
CALCULATE (
SUM ( 'Table'[Amount] ),
ALLEXCEPT ( 'Table', 'Table'[OrderHeader] )
)
)
RETURN
SUMX (
FILTER ( '_Table_Total_Header', [Header_Total] >= 1000 ),
'Table'[Amount]
)
Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!
Best regards,
Joao Ribeiro
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.
User | Count |
---|---|
88 | |
79 | |
63 | |
61 | |
59 |
User | Count |
---|---|
166 | |
114 | |
99 | |
73 | |
65 |