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
Anonymous
Not applicable

Calculate rolling 12

Good morning,

 

How can I calculate rolling 12 without using a calendar table, but using the date field that comes from the database which has the format 01012021 for example.

 

Thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

I think you can build a number type YearMonth column and a Rank column to calcualte rolling 12.

YearMonth and Rank columns are calculated columns.

YearMonth = RIGHT('Sample'[Date],4)*100+LEFT('Sample'[Date],2)
RANK = RANKX('Sample',[YearMonth],,ASC,Dense)

1.png

Rolling 12 measure:

Rolling 12 = 
CALCULATE(SUM('Sample'[Value]),FILTER(ALL('Sample'),'Sample'[RANK]>MAX('Sample'[RANK])-12&&'Sample'[RANK]<=MAX('Sample'[RANK])))

Result:

1.png

Best Regards,
Rico Zhou

 

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
Anonymous
Not applicable

Hi @Anonymous 

I think you can build a number type YearMonth column and a Rank column to calcualte rolling 12.

YearMonth and Rank columns are calculated columns.

YearMonth = RIGHT('Sample'[Date],4)*100+LEFT('Sample'[Date],2)
RANK = RANKX('Sample',[YearMonth],,ASC,Dense)

1.png

Rolling 12 measure:

Rolling 12 = 
CALCULATE(SUM('Sample'[Value]),FILTER(ALL('Sample'),'Sample'[RANK]>MAX('Sample'[RANK])-12&&'Sample'[RANK]<=MAX('Sample'[RANK])))

Result:

1.png

Best Regards,
Rico Zhou

 

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

Ashish_Mathur
Super User
Super User

Hi,

It will be ideal to convert 01012020 to a proper date, then build a Calendar Table and then use the Date and Time Intelligence functions to get your desired result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ryan_mayu
Super User
Super User

@Anonymous 

you need to change the format to date type. and use DATEADD

https://docs.microsoft.com/en-us/dax/dateadd-function-dax

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.