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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Create and compare custom time periods

Hi All,

 

I'm looking to create custom time period so I can compare the last 12 months of sales from this month (as today is in Nov 2021, I would want Nov 2020 - Oct 2021) to the previous 12 months prior to that (Nov 2019 - Oct 2020).

 

I would like this to update dynamically when the data is refreshed each month. 

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here’s my solution.

1.Create a calendar table.

vkalyjmsft_0-1636939920065.png

 

2.Rank the table by month.

RANK = RANKX('Table 2',[YearMonth],,DESC,Dense)

3.Create relationship of the two tables.

vkalyjmsft_1-1636939920068.png

 

4.Create three measure.

Last 12 months sales = CALCULATE(SUM('Table'[Sales]),'Table 2'[RANK]IN{2,3,4,5,6,7,8,9,10,11,12,13})

Previous 12 months sales = CALCULATE(SUM('Table'[Sales]),'Table 2'[RANK]IN{14,15,16,17,18,19,20,21,22,23,24,25})

Compare = DIVIDE([Last 12 months sales],[Previous 12 months sales])

vkalyjmsft_2-1636939920073.png

 

Best Regards,
Community Support Team _ kalyj

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

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here’s my solution.

1.Create a calendar table.

vkalyjmsft_0-1636939920065.png

 

2.Rank the table by month.

RANK = RANKX('Table 2',[YearMonth],,DESC,Dense)

3.Create relationship of the two tables.

vkalyjmsft_1-1636939920068.png

 

4.Create three measure.

Last 12 months sales = CALCULATE(SUM('Table'[Sales]),'Table 2'[RANK]IN{2,3,4,5,6,7,8,9,10,11,12,13})

Previous 12 months sales = CALCULATE(SUM('Table'[Sales]),'Table 2'[RANK]IN{14,15,16,17,18,19,20,21,22,23,24,25})

Compare = DIVIDE([Last 12 months sales],[Previous 12 months sales])

vkalyjmsft_2-1636939920073.png

 

Best Regards,
Community Support Team _ kalyj

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

Greg_Deckler
Community Champion
Community Champion

@Anonymous You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors