Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Penguin12
New Member

Sum values only with a threshold based on header level

Hi!

I have this kind of data structure 

 

OrderHeaderOrderItemAmount
A1100
A2200
B5200
A3800
C41005

 

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

OrderItemAmount
1100
2200
3800
41005

 

1 ACCEPTED 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

 

View solution in original post

3 REPLIES 3
Penguin12
New Member

@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

 

joaoribeiro
Impactful Individual
Impactful Individual

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]
    )

joaoribeiro_0-1701087219285.png

 

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.