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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Sum values of Measure 1 when condition applies to measure 2

Hi all, 

 

I'm trying to create a measure that sums the values of a measure (1) when the values of another measure (2) is above 20. 

 

I have tried different measures I found in the forum but none of them seems to work. (Note: Measure 1 and Measure 2 can change depending on the time bucket I apply)

 

e.g I tried  CALCULATE( [Customers], IF ([Spend]>20)), I tried variations of SUMX and didn't get a result

 

 Measure 1Measure 2Measure Neeeded
Time BucketCustomersSpend 
00:00 - 00:15104510
00:15 - 00:30254025
00:30 - 00:45304030
00:45 - 01:00510 
01:00 - 01:158020 
01:15 - 01:309010 
01:30 - 01:4510015 
01:45 - 02:0012058120
02:00 - 02:15905090

 

Can anyone help?

 

Many thanks in advance

1 ACCEPTED SOLUTION

I created a _Summary_ table that has columns named [@Customers] and [@Spend] and the used SUMX to iterate over the _Summary_ table, filtering on the [@Spend] column and summing on the [@Customers] column.

 

This pattern works assuming [Customers] and [Spend] are columns of 'Table'. If those are actually measures instead of columns, then the DAX is slightly simpler:

BigSpenders =
VAR _Summary_ =
    ADDCOLUMNS (
        SUMMARIZE ( 'Table', 'Table'[Time Bucket] ),
        "@Customers", [Customers],
        "@Spend", [Spend]
    )
RETURN
    SUMX ( FILTER ( _Summary_, [@Spend] > 20 ), [@Customers] )

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

You can create a calculated table within a measure that you then apply SUMX to like this:

 

BigSpenders =
VAR _Summary_ =
    ADDCOLUMNS (
        SUMMARIZE ( 'Table', 'Table'[Time Bucket] ),
        "@Customers", CALCULATE ( SUM ( 'Table'[Customers] ) ),
        "@Spend", CALCULATE ( SUM ( 'Table'[Spend] ) )
    )
RETURN
    SUMX ( FILTER ( _Summary_, [@Spend] > 20 ), [@Customers] )
Anonymous
Not applicable

Hi @AlexisOlson 

 

I appreciate the help.

 

I don't seem to be able to select the measures in the sum functions...

 

I believe this works with the native columns but does not seem to work with my measures (@Customers & @Spend)

 

 

I created a _Summary_ table that has columns named [@Customers] and [@Spend] and the used SUMX to iterate over the _Summary_ table, filtering on the [@Spend] column and summing on the [@Customers] column.

 

This pattern works assuming [Customers] and [Spend] are columns of 'Table'. If those are actually measures instead of columns, then the DAX is slightly simpler:

BigSpenders =
VAR _Summary_ =
    ADDCOLUMNS (
        SUMMARIZE ( 'Table', 'Table'[Time Bucket] ),
        "@Customers", [Customers],
        "@Spend", [Spend]
    )
RETURN
    SUMX ( FILTER ( _Summary_, [@Spend] > 20 ), [@Customers] )
Anonymous
Not applicable

Thanks @AlexisOlson, the last code worked like a charm! Many thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.