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

Cumulative Running Total with Missing Values

Hi, Im fairly new to Power BI and I'm struggling to work out how to avoid my cumulative/YTD running total line graph dipping back down to zero when I don't have any values in a particular month. It should stay at the previous months YTD figure. 

 

My current measure is as follows:

 

YTD Cumulative = calculate([Total Agreements],FILTER(ALLSELECTED (agreements),([executiondate] <= MAX(agreements[executiondate]))),GROUPBY('Date','Date'[Fiscal Year]))

 

where Total Agreements = if(COUNTROWS(agreements) = BLANK(), 0, COUNTROWS(agreements))

 

The graph currently looks like this:

 

Capture.PNG

As you can see the line at Dec 2016 dips back down to zero (because there were no occurances in that month) before going back up in January, but it should stay as a horizontal line in reality as the YTD total remains the same.

 

I did have Total Agreements = COUNTROWS(agreements), but that gave me a broken line graph (which is also wrong), hence the addition of the IF statement. 

 

If it is important to know, the data is coming from Dynamics.

 

Any thoughts would be very gratefully received.

 

Thanks!

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Please try this:

Total Agreements = COUNTROWS(agreements)

YTD Cumulative =
IF (
    COUNTROWS ( agreements ) = BLANK (),
    CALCULATE (
        [Total Agreements],
        FILTER (
            ALLSELECTED ( agreements ),
            (
                MONTH ( [executiondate] )
                    <= MONTH ( MAX ( agreements[executiondate] ) ) - 1
            )
        ),
        GROUPBY ( 'Date', 'Date'[Fiscal Year] )
    ),
    CALCULATE (
        [Total Agreements],
        FILTER (
            ALLSELECTED ( agreements ),
            ( [executiondate] <= MAX ( agreements[executiondate] ) )
        ),
        GROUPBY ( 'Date', 'Date'[Fiscal Year] )
    )
)

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi there @v-yulgu-msft,

 

Thanks for looking into this problem for me, but unfortunately that doesn't seem to be working as that gives me a broken line for that missing month.

 

I created 2 new measures called v2Total Agreements & v2YTD Cumulative (rather than changing my current ones) and this is how the graph now looks and I created a table to show the actual figures for my original measures and the new ones:

 

 

 

Capture.PNGCapture2.PNG

 

As you can see there is no figure for v2YTD Cumulative for December Fiscal Year 2016, I'm trying to get it to say 21 (which is the same figure for November).

 

Really appreciate you looking into this for me.

 

Just to confirm here is the new measure created:

 

v2YTD Cumulative =
IF (
COUNTROWS ( agreements ) = BLANK (),
CALCULATE (
[v2Total Agreements],
FILTER (
ALLSELECTED ( agreements ),
(
MONTH ( [executiondate] )
<= MONTH ( MAX ( agreements[executiondate] ) ) -1
)
),
GROUPBY ( 'Date', 'Date'[Fiscal Year] )
),
CALCULATE (
[v2Total Agreements],
FILTER (
ALLSELECTED ( agreements ),
( [executiondate] <= MAX ( agreements[executiondate] ) )
),
GROUPBY ( 'Date', 'Date'[Fiscal Year] )
)
)

 

Thanks,

Andy

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.