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
Qotsa
Helper V
Helper V

How to perform calculations on this measure

Hi,

 

I have this measure: 

Rest Period Decimal Hrs =
VAR thisdate =
MIN ( 'powerbi114 view_finance'[Date] )
VAR thisfirst =
MIN ( [Time of First Call] )
VAR prevdate =
CALCULATE (
MAX ( 'powerbi114 view_finance'[Date] ),
ALL ( 'powerbi114 view_finance' ),
VALUES ( 'powerbi114 view_finance'[carer_id] ),
'powerbi114 view_finance'[Date] < thisdate
)
VAR prevlast =
CALCULATE (
MAX ( 'powerbi114 view_finance'[Time of Last Call] ),
ALL ( 'powerbi114 view_finance' ),
VALUES ( 'powerbi114 view_finance'[carer_id] ),
'powerbi114 view_finance'[Date] = prevdate
)
RETURN
IF (
NOT ( ISBLANK ( prevdate ) ),
24
* FIXED ( ( thisdate + thisfirst ) - ( prevdate + prevlast ), 3 )
)
 
It returns the time between the Latest Finish Time from the previous date and the Earliest Start Time of the next date for each carer_id.
 
Qotsa_1-1656490890862.png

 


 

The issue I am having is how to perform calculations on the measure.

For example, I want a sum of all values < 11 but sumx does not work with boolean values.

 

Less than 11 = SUMX('powerbi114 view_finance',[Daily Rest Decimal Hrs] < 11)
 
Qotsa_2-1656493946868.png

 

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Qotsa try:

 

Less than 11 = 
SUMX(
    FILTER(
        SUMMARIZE(        
            'powerbi114 view_finance',
            'powerbi114 view_finance'[carer_id],
            'powerbi114 view_finance'[Date]
       )
        [Daily Rest Decimal Hrs] < 11
    )
    ,1
)

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

View solution in original post

13 REPLIES 13
Qotsa
Helper V
Helper V

Thks again. Can you explain what is happening here?

SUMX(
    FILTER(
        SUMMARIZE(        
            'powerbi114 view_finance',
            'powerbi114 view_finance'[carer_id],
            'powerbi114 view_finance'[Date]
       )
SpartaBI
Community Champion
Community Champion

SUMMARIZE(        
            'powerbi114 view_finance',
            'powerbi114 view_finance'[carer_id],
            'powerbi114 view_finance'[Date]
       )

This is the distinct combination of these 2 columns.
Check out:
https://dax.guide/summarizea


 

Ok. Thanks very much.

SpartaBI
Community Champion
Community Champion

@Qotsa my pleasure 🙂
Don't forget to check out my showcase report - really, got some high level stuff there. Sure you will find there a lot of cool ideas. 
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂

SpartaBI
Community Champion
Community Champion

@Qotsa I think you are trying to do:
Less than 11 = SUMX(FILTER('powerbi114 view_finance',[Daily Rest Decimal Hrs] < 11),[Daily Rest Decimal Hrs])
 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

@SpartaBI Thks. I'm not getting desired results. Should return a sum of 2.

Qotsa_0-1656498231428.png

 

SpartaBI
Community Champion
Community Champion

@Qotsa oh, so do this:) :
Less than 11 = SUMX(FILTER('powerbi114 view_finance',[Daily Rest Decimal Hrs] < 11),1)


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

It's getting closer.

Qotsa_0-1656502631818.png

 

SpartaBI
Community Champion
Community Champion

@Qotsa try:

 

Less than 11 = 
SUMX(
    FILTER(
        SUMMARIZE(        
            'powerbi114 view_finance',
            'powerbi114 view_finance'[carer_id],
            'powerbi114 view_finance'[Date]
       )
        [Daily Rest Decimal Hrs] < 11
    )
    ,1
)

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

That's fantastic. I'm getting the correct results for <11.

When I change it tho to =, it doesn't return the desired result. Any idea why?

 

Qotsa_0-1656508503529.png

 

SpartaBI
Community Champion
Community Champion

@Qotsa I guess it's not exactly 32.26 🙂
Try to verify by doing 

 

Less than 11 = 
SUMX(
    FILTER(
        SUMMARIZE(        
            'powerbi114 view_finance',
            'powerbi114 view_finance'[carer_id],
            'powerbi114 view_finance'[Date]
       )
        [Daily Rest Decimal Hrs] > 32 && [Daily Rest Decimal Hrs] < 33 
    )
    ,1
)

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Yep, that gives correct result.

Qotsa_0-1656510031442.png

 

SpartaBI
Community Champion
Community Champion

@Qotsa my pleasure 🙂
Please don't forget to accept the previous message as a solution for community visibility.
P.S. Check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. 
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂

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.