Forum Discussion
Sum values only with a threshold based on header level
- 2 years ago
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