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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Running 12 month calculation for prior year

Hello, 

 

I have a slicer set up like this:

JMikes_1-1686932556513.png

 

Using this slicer, I calculate CY and PY YTD gross revenue with the following commands:

CYTotalGrossRevenue = SUMX(DISTINCT('ADM VW_ClubsDaysToPayv2'[order_id]), CALCULATE(MAX('ADM VW_ClubsDaysToPayv2'[gross_rev])))  + SUM('ADM VW_ClubsDaysToPayv2'[late_fee])
 
PYTotalGrossRevenue = CALCULATE([CYTotalGrossRevenue], DATEADD('dim CalendarDate'[CalendarDateKey], -1, YEAR))
 
This works fine. But I also need two 12-month running gross revenue totals from 1-year and also 16-months prior to the max date of the slicer. So, 6/10/2021 to 6/10/2022 and also 2/10/2021 to 2/10/2022.
 
What is the best way to approach this? 
 
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

HI , @Anonymous 

According to your description, you want to " two 12-month running gross revenue totals from 1-year and also 16-months prior to the max date of the slicer".

Here are the steps you can refer to :
(1)This is my test data , you can see if i understand your need:

vyueyunzhmsft_0-1687154062032.png

vyueyunzhmsft_1-1687154087099.png

 

 

(2)We can create two measure like this:

Running 1-year = var _slicer = MAXX( ALLSELECTED('dim CalendarDate') ,[CalendarDateKey])
var _pre12years = EDATE(_slicer,-12)
var _pre24years = EDATE(_slicer,-24)
var _t =FILTER( ADDCOLUMNS( ALL('dim CalendarDate') , "CY" , [CYTotalGrossRevenue]) , [CalendarDateKey]>=_pre24years && [CalendarDateKey]<= _pre12years)

return
sumx(_t,[CY])
Running 16-months = var _slicer = MAXX( ALLSELECTED('dim CalendarDate') ,[CalendarDateKey])
var _pre16years = EDATE(_slicer,-16)
var _pre28years = EDATE(_slicer,-28)
var _t =FILTER( ADDCOLUMNS( ALL('dim CalendarDate') , "CY" , [CYTotalGrossRevenue]) , [CalendarDateKey]>=_pre28years && [CalendarDateKey]<= _pre16years)

return
sumx(_t,[CY])

 

Then  we can put the measure on the visual and we can get this:

vyueyunzhmsft_2-1687154133906.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

HI , @Anonymous 

According to your description, you want to " two 12-month running gross revenue totals from 1-year and also 16-months prior to the max date of the slicer".

Here are the steps you can refer to :
(1)This is my test data , you can see if i understand your need:

vyueyunzhmsft_0-1687154062032.png

vyueyunzhmsft_1-1687154087099.png

 

 

(2)We can create two measure like this:

Running 1-year = var _slicer = MAXX( ALLSELECTED('dim CalendarDate') ,[CalendarDateKey])
var _pre12years = EDATE(_slicer,-12)
var _pre24years = EDATE(_slicer,-24)
var _t =FILTER( ADDCOLUMNS( ALL('dim CalendarDate') , "CY" , [CYTotalGrossRevenue]) , [CalendarDateKey]>=_pre24years && [CalendarDateKey]<= _pre12years)

return
sumx(_t,[CY])
Running 16-months = var _slicer = MAXX( ALLSELECTED('dim CalendarDate') ,[CalendarDateKey])
var _pre16years = EDATE(_slicer,-16)
var _pre28years = EDATE(_slicer,-28)
var _t =FILTER( ADDCOLUMNS( ALL('dim CalendarDate') , "CY" , [CYTotalGrossRevenue]) , [CalendarDateKey]>=_pre28years && [CalendarDateKey]<= _pre16years)

return
sumx(_t,[CY])

 

Then  we can put the measure on the visual and we can get this:

vyueyunzhmsft_2-1687154133906.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

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.