cancel
Showing results for
Search instead for
Did you mean:
Regular Visitor

## 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:

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
Microsoft

## Re: Cumulative Running Total with Missing Values

Hi @Andy_W1,

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.
Regular Visitor

## Re: Cumulative Running Total with Missing Values

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:

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

#### Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

#### Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors