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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

12m rolling do not show line if no actuals

Hi all, 

 

I have used this formula to produce a 12 month moving average line: 

 

12m Rolling =
CALCULATE(CALCULATE(
[in M] ,DATESINPERIOD(
dim_Calendar[Date] ,MAX(dim_Calendar[Date])
,-12
,MONTH
)
), Ranked_Version[Version]="Actual")/12
 
My issue here is that on the months which i do not have actuals e.g., Nov and Dec, I do not want to show any value in the moving average line but instead show blank. 
 
 
Thanks all for your help! 
1 ACCEPTED SOLUTION
MartynRamsden
Solution Sage
Solution Sage

Hi @Anonymous 

 

You could use an IF function to test your 'Actual' measure and if it's blank, return blank, otherwise calculate your 12 month average.

Something like this:

 

12m Rolling =
VAR Actual = [Actual Measure]
VAR Result =
    IF (
        ISBLANK ( Actual ),
        BLANK (),
        CALCULATE (
            CALCULATE (
                [in M],
                DATESINPERIOD ( dim_Calendar[Date], MAX ( dim_Calendar[Date] ), -12, MONTH )
            ),
            Ranked_Version[Version] = "Actual"
        ) / 12
    )
RETURN
    Result

View solution in original post

1 REPLY 1
MartynRamsden
Solution Sage
Solution Sage

Hi @Anonymous 

 

You could use an IF function to test your 'Actual' measure and if it's blank, return blank, otherwise calculate your 12 month average.

Something like this:

 

12m Rolling =
VAR Actual = [Actual Measure]
VAR Result =
    IF (
        ISBLANK ( Actual ),
        BLANK (),
        CALCULATE (
            CALCULATE (
                [in M],
                DATESINPERIOD ( dim_Calendar[Date], MAX ( dim_Calendar[Date] ), -12, MONTH )
            ),
            Ranked_Version[Version] = "Actual"
        ) / 12
    )
RETURN
    Result

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.