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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Stella_V
Frequent Visitor

How can I calculate a hourly difference between two dates on a measure?

Hello,

I have the following dataset and I want to calculate the difference between the 24.10.2023 Hour 1 and the 23.10.2023 Hour 1, and generally for each hour, between both days. I have already defined two measures as "Measure A, T" and "Measure A, T-1", being "T as today" and "T-1 as yesterday" . But I dont know how to calculate the difference between these two measures on a hourly basis.

 

Result should look like the image attached, equal to an hourly difference for every day.

 TimeHourMeasure A
D24.10.20231.000.009632
D24.10.20232.000.615008
D24.10.20233.000.712107
D24.10.20234.000.357265
D24.10.20235.000.922201
D-123.10.20231.000.468224
D-123.10.20232.000.447249
D-123.10.20233.000.096913
D-123.10.20234.000.714057
D-123.10.20235.000.61969
    
 DifferencehourMeasure A
 24.10.2023 - 23.10.20231.00-0.45859
 24.10.2023 - 23.10.20232.000.167759
 24.10.2023 - 23.10.20233.000.615194
 24.10.2023 - 23.10.20234.00-0.35679
 24.10.2023 - 23.10.20235.000.302511

thank you very much for your help

Kind regards

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Stella_V 

 

You can try the following methods.

Previous Measure A = CALCULATE([Measure A],FILTER(ALL('Table'),[Time]=SELECTEDVALUE('Table'[Time])-1&&[Hour]=SELECTEDVALUE('Table'[Hour])))
Difference = IF([Previous Measure A]=BLANK(),BLANK(),[Measure A]-[Previous Measure A])

vzhangti_0-1698231572819.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Stella_V
Frequent Visitor

Hello

sorry but it does not work actually the way i wanted. The "Mesure A" is not a measure but a value within the table. I called it wrong with measure. Also, I need to add one condition, as such:

- I need to calculate the hourly difference between D and D-1 between two countries as shown below:

Stella_V_0-1698331482669.png

 

i think we would do an additional filter on the country?

thanks a lot

 

Stella_V
Frequent Visitor

Yes that's the result i expect. Works perfectly, thank you 🙂 !!!

v-zhangti
Community Support
Community Support

Hi, @Stella_V 

 

You can try the following methods.

Previous Measure A = CALCULATE([Measure A],FILTER(ALL('Table'),[Time]=SELECTEDVALUE('Table'[Time])-1&&[Hour]=SELECTEDVALUE('Table'[Hour])))
Difference = IF([Previous Measure A]=BLANK(),BLANK(),[Measure A]-[Previous Measure A])

vzhangti_0-1698231572819.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.