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
Arendp
Helper III
Helper III

previous period calculation based on variable time range

hello, I am struggling with the following calculation.

I have date slicer, where a user can select a variable time period. 
For example user selects 3.May.2021 till 5.May.2021.
I want to compare figures with the same amount of days before. 
So previous period will be 30.April.2021 till 2.May.2021.

Arendp_0-1627647165731.png

 


How to create the calcuation for the period before? I have a DateRangeMin vs Max, but it works on total level only, not when I want to calculate it for each date in the time frame.

Arendp_2-1627647308391.png

 

Arendp_4-1627647412276.png

Here it needs to be -3 for each line, so I can calculate back to each previous period line with the function dateadd(date,-3,day).

So right now 3.May looks at 2.May, 4.May looks at 3.May, while it should be: 3.May look at 30.Apr, and 4.May looks at 1.May.

 

Hopefully my question is clear and somebody can point me in the right direction.

 

1 ACCEPTED SOLUTION
Arendp
Helper III
Helper III

Thanks for your reply!

I managed to solve it otherwise. The datediff was achieved also by a countrows on my second datetable.

View solution in original post

2 REPLIES 2
Arendp
Helper III
Helper III

Thanks for your reply!

I managed to solve it otherwise. The datediff was achieved also by a countrows on my second datetable.

Mohammad_Refaei
Solution Specialist
Solution Specialist

Try to add ALLSELECTED ('Calendar'[Date])  to your DateRangeMin and DateRangeMin measures.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.