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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
joshl525
New Member

How to correctly add rolling 12 months

Hello, team, 

I was trying to add the last 12 months total value for the "Valor" Column using the following formula: 

CALCULATE(
SUM('BD_Core'[Valor]), 'BD_Core'[Versión] = "VR",
FILTER(
ALL('BD_Core'[Monthyear]),
'BD_Core'[Monthyear] <= TODAY() && 'BD_Core'[Monthyear] >= TODAY() -365
))

So, for instance, in February 2025 it should display the total amount of Feb 2024 to Jan 2025. 

However, the only thing it does is to display only the same value of the column, not adding the last 12 months for the month selected. Any help on this? 

 

Thanks in advance. 

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try to use KEEPFILTERS DAX function in the measure.

Please try to write something like below, and please check whether it suits your requirement.

 

KEEPFILTERS, functie (DAX) - DAX | Microsoft Learn

 

CALCULATE (
    SUM ( 'BD_Core'[Valor] ),
    'BD_Core'[Versión] = "VR",
    KEEPFILTERS (
        FILTER (
            ALL ( 'BD_Core'[Monthyear] ),
            'BD_Core'[Monthyear] <= TODAY ()
                && 'BD_Core'[Monthyear]
                    >= TODAY () - 365
        )
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
MasonMA
Resident Rockstar
Resident Rockstar

@joshl525 

 

Hi, i'm not sure if your [Monthyear] can be used to compare directly to TODAY(). I'd suggest using a separate, dedicated Date table with a relationship to BD_Core. Then you can use DATESINPERIOD or DATEADD for rolling 12 months.

 

Create a proper Date table and mark it as Date table under Modelling tab. Connect it to your 'BD_Core' with one-to-many, then use this sample DAX for rolling 12 months

 

Measure =
CALCULATE (
    SUM ( 'BD_Core'[Valor] ),
    'BD_Core'[Versión] = "VR",
    DATESINPERIOD (
        'Date'[Date],           
        MAX ( 'Date'[Date] ),        -- current context date
        -12, MONTH                   -- go back 12 months
    )
)

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.