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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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