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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
romilv1
Helper I
Helper I

How to calculate previous 12 month total based on user month selection?

Hello All,

When user selects say year as 2025 and month as January it should show past 12 months of data (i.e. data from Feb 2024 to Jan 2025). We have dim_date table and we want to show sum of revenue.

 

What should be the dax? We also want to include "USE RELATIONSHIP" as the relationship is not active between Revenue table and dim_date table?


Thanks

1 ACCEPTED SOLUTION
mariussve1
Super User
Super User

I was little to fast, dateadd just shows the value on that point, but rolling 12m we need to use DATESINPERIOD():

 

Rolling 12m = 
DATESINPERIOD(Dim_date[Date], MAX(Dim_date[Date]), -12, MONTH)


Br
Marius
BI Fabrikken
www.bifabrikken.no

View solution in original post

8 REPLIES 8
mariussve1
Super User
Super User

I was little to fast, dateadd just shows the value on that point, but rolling 12m we need to use DATESINPERIOD():

 

Rolling 12m = 
DATESINPERIOD(Dim_date[Date], MAX(Dim_date[Date]), -12, MONTH)


Br
Marius
BI Fabrikken
www.bifabrikken.no

Yes got the solution from other posts. But thanks for this. It helped!

mariussve1
Super User
Super User

Hi,

 

Im having relative_month in my date table, then it would be:

 

Calculate( Sum ( 'Table'[Column] ), USERELATIONSHIP(), 'Date'[Relative_month] = -12 )

 

In the USERELATIONSHIP() you need to adjust to the columns you have connected in the inactive relationship.

 

Instead of relative_month you can use DATEADD(), but for it to work the date table need to be marked as date table first.


Br
Marius
BI Fabrikken
www.bifabrikken.no

romilv1_0-1741628161533.png

Does this look correct? I use this and the chart went blank!

Hi,

 

Are you able to share your model with me, or a smaller part of it that is relevant?


Br
Marius
BI Fabrikken
www.bifabrikken.no

romilv1_0-1741628449735.png

Does this look correct? This doesn't bring values

Expected value

romilv1_1-1741628496985.png

 

Date_Add value

 

romilv1_2-1741628513618.png

 




Im sorry, we need to create rolling 12 months.

 

are you able to share your model? If not I Can try create a demo model for you to show 🙂


Br
Marius
BI Fabrikken
www.bifabrikken.no

Dim_date is already a date table.

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.