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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
kjohnanand
Helper I
Helper I

How to get Rolling 12 revenue while filtering on a specific date for another field in DAX

I am trying to get a rolling 12 revenue figure for active clients filterable by quarter and year. My current function uses a Quarter Index to calculate for the past 12 months. Here it is.

 

 

 

Rev R12 12 = 
VAR _lastq = MAX('RCB Core Revenue'[Quarter Index])
VAR _firstq = _lastq - 4
VAR _res = CALCULATE(
SUM('RCB Core Revenue'[Revenue]), 'RCB Core Revenue'[Active vs Deconverted] = "Active",
FILTER(ALL(_QuarterEndTable), '_QuarterEndTable'[Quarter Index] > _firstq && '_QuarterEndTable'[Quarter Index] <= _lastq))
RETURN _res

 

 

 

The basic outline of this seems to work relatively well, but the issue I'm having is that It's adding up the revenue for clients that were active in any/all 4 quarters in the rolling 12 when I only want the active filter to be applied to the max quarter in the function. For example, if I pick Q4 2023, I only want to see clients that were active in that specific quarter rather than clients that were active throughout the entire 12 month period, while still pulling the full rolling 12 revenue. Right now I'm finding that it either gives me the revenue for all active clients in all 4 quarters or it filters to active in the last quarter but only gives me the revenue for that quarter rather than the full Rolling 12.

 

I figured out that the issue is most likely due to the ALL() function in my calculation, so I was trying to find something that allowed me to filter on multiple variables at once. For example, keep the ALL() but then stipulate that the "active" filter only be applied to the max quarter in the range. Any assistance on this would be appreciated!

4 REPLIES 4
v-kongfanf-msft
Community Support
Community Support

Hi @kjohnanand ,

 

Try to modify your formula like below:

Rev R12 12 = 
VAR _lastq = MAX('RCB Core Revenue'[Quarter Index])
VAR _firstq = _lastq - 4
VAR _maxQuarterActiveClients = CALCULATETABLE(
    VALUES('RCB Core Revenue'[ClientID]),
    'RCB Core Revenue'[Quarter Index] = _lastq,
    'RCB Core Revenue'[Active vs Deconverted] = "Active"
)
VAR _res = CALCULATE(
    SUM('RCB Core Revenue'[Revenue]),
    FILTER(
        ALL('RCB Core Revenue'),
        'RCB Core Revenue'[Quarter Index] > _firstq && 'RCB Core Revenue'[Quarter Index] <= _lastq
    ),
    TREATAS(_maxQuarterActiveClients, 'RCB Core Revenue'[ClientID])
)
RETURN _res

vkongfanfmsft_1-1710912777558.png

Best Regards,
Adamk Kong

 

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

Thank you for the reply. It looks like I'm getting a rolling 12 now, but the revenue number is higher than it should be. FY 2023 should be around 2.75bn, but I'm getting over 3bn. I think there's ann issue with the active clients filter. Here's my data if that helps.

 

Sample Data.xlsx

Hi @kjohnanand ,

 

I can't access the link you provided at the moment, please check and reshare.

 

Best Regards,
Adamk Kong

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.