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
Soof1234
Helper I
Helper I

Compare dates based on date selection.

Hi,


To start with, I couldnt find a proper title for my case.

The issue:

I have a dateslicer which I want to use to filter several measure that calculate turnover, hours made, occupancy etc. Next to those measures I have separate measures that calculate the difference between selected month and month before selected month. This works fine. However if I select two months for example it must compare the difference between the selected two months and the two months before that.

For example, if i select the months july and august, it must compare the months july and august to the months may and june. What currently happens when I select july and august is that it compares it to june and july. This must apply the same way for selecting a year, quarter, 6 months etc.

This is currently one of the measures that I use to compare the difference. 

_Totaal_Uren_verschil =
 
VAR Uren = [_Totaal_uren]
VAR Uren_vorige_maand = CALCULATE([_Totaal_uren], DATEADD('Datum'[Date],-1,MONTH))

VAR verschil = (Uren - Uren_vorige_maand) / Uren_vorige_maand

Return verschil

It makes sense in this case that it compares it to the previous month, but I have no clue what measure to use for my desired solution.

Kind Regards,

Soof1234
1 REPLY 1
Soof1234
Helper I
Helper I

Happy to find the solution myself, was as simple as it could be afterwards:)

Just added a count of the selected months was sufficient. 

_Totaal_Uren_verschil =

Var Aantal_Maanden = COUNT(Datum[Maand])
VAR Uren = [_Totaal_uren]
VAR Uren_vorige_maand = CALCULATE([_Totaal_uren], DATEADD('Datum'[Date],0-Aantal_Maanden,MONTH))

VAR verschil = (Uren - Uren_vorige_maand) / Uren_vorige_maand

Return verschil

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors