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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How to dynamically change 2 periods of comparison?

Hello,

 

Is there a smart way to change how I compare 2 periods of the same length?

Right now I have formulas that compare last 3 months vs last 3-6 months. To do this, I have just created a conditional column based on a relative month column (see first picture).

So I have these formulas to compare the periods:

 

Turnover L3M = CALCULATE(SUM('InitiativeMonitor_table'[Turnover (DKK)]),'InitiativeMonitor_table'[Period select2]="Period1")

Turnover L3-6M = CALCULATE(SUM('InitiativeMonitor_table'[Turnover (DKK)]),'InitiativeMonitor_table'[Period select2]="Period2")
Delta Turnover = [Turnover L3M]-[Turnover L3-6M]
 
etc. also with same formulas for Profit, Profit Margin % and Cost.
 
But if I would like to compare last 30 days vs last 30-60 days for example or last 6 months vs last 6-12 months or some other periods.Is there a smart way to accomplish this? Without editing the query and modifying or making new conditional columns.
 
 kolovez_0-1625042932420.png
kolovez_1-1625043214581.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Create rolling measures

 

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

Rolling 3 before 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),3),-3,MONTH))

 

 

Rolling 30 day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]),-30,Day))

 

Rolling 30 day before 30 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]) -30   ,-30,Day))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , Create rolling measures

 

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

Rolling 3 before 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),3),-3,MONTH))

 

 

Rolling 30 day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]),-30,Day))

 

Rolling 30 day before 30 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]) -30   ,-30,Day))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors