cancel
Showing results for
Did you mean:
Frequent Visitor

## Visual Filter for Cumulative Sum Issue

Hi,

I need some help with cumulative sum line.

Before selecting any slicer, the visual shows this:

But after applying filter, the visual shows the below.

How then can I make the line graph show the full graph, starting from zero to the end of the chart, similar to the first screenshot?

Regards,
Nicholas Hiew

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User

## Re: Visual Filter for Cumulative Sum Issue

@NicklancerUpdate cummulative total DAX as give below and that will do it, as @Seward12533 suggested to use cross filter to both direction, it has performance hit but instead of setting up the relationship, you can use it in DAX formula basically you are using cross filter to both direction when required

```Cumulative =
CALCULATE(
SUM('Table2'[Count]),
CROSSFILTER(Table1[Week of Year],Table2[Week No.], Both),
FILTER(ALL('Table2'),
'Table2'[Week No.]<=MAX('Table2'[Week No.]))
)

```

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut! Connect with me on Linkedin.
Feel free to email me with any of your BI needs.

New Contributor

## Re: Visual Filter for Cumulative Sum Issue

@Nicklancer try this

```Cumulative = VAR Result =
CALCULATE(
SUM('Table2'[Count]),
CROSSFILTER(Table1[Week of Year],Table2[Week No.], Both),
FILTER(ALL('Table2'),
'Table2'[Week No.]<=MAX('Table2'[Week No.]))
)
RETURN
IF(Result,Result,0)```
17 REPLIES 17
Super User

## Re: Visual Filter for Cumulative Sum Issue

Can you share sample data and what is your current measure?

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut! Connect with me on Linkedin.
Feel free to email me with any of your BI needs.

New Contributor

## Re: Visual Filter for Cumulative Sum Issue

Also what is your desired result? do you want the **bleep** to be unaffected by the filter or do you want the scale to be fixed?  The problem is the **bleep** is being plotted on its own axis and PBI is dynamically adjusting it based on the data. Or do you want the other data to not be displayed and only show the filtered data?

If you want the **bleep** to adjust.

Look at either turning off the secondary Y axis to you **bleep** is plotted on the same scale (probably not what you want) or fixing the scales manually

If you want the **bleep** not be affected make sure you the USE the ALL filter(s) for the slicers your using

If you want the other data to be filtered out then adjust the visual interations and chose filter.

Frequent Visitor

## Re: Visual Filter for Cumulative Sum Issue

Hi Both,

This is my desired result (lines in red), when sliced by category.

My Data (Table 1) looks like this, with the last column "Week No." is created in query editor:

And I have another table (Table 2) created to give me the following value (only the first column is from an excel sheet):

For cumulative column (note that I use excel to replicate these), I used the following measure:

Cumulative =
CALCULATE(
SUM('Table 2'[Count]),
FILTER(ALL('Table 2'),
'Table 2'[Week No.]<=MAX('Table 2'[Week No.]))
)

EDIT: I also tried adding a column for cumulative, which still yield the same visual results:

Cumulative =
CALCULATE(
SUM('Table 2'[Count]),
FILTER(ALL('Table 2'),
'Table 2'[Week No.]<=EARLIER('Table 2'[Week No.]))
)

Appreciate your help. Thanks.

Regards,
Nicholas

Super User

## Re: Visual Filter for Cumulative Sum Issue

Hey @Nicklancer Can you share the data in excel sheet for the solution?

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut! Connect with me on Linkedin.
Feel free to email me with any of your BI needs.

New Contributor

## Re: Visual Filter for Cumulative Sum Issue

Rather than have the the week number come from your fact/data table have use the week number from the date table.

The **bleep** Measure would be following this pattern.

**bleep** = CALCULATE(sum(fact[value],all(date),filter(date,date[date]<=max(date[date]))

In your case since you only want cume YTD you would need to add a condition to filter out prior and future years &&date[year]=year(now())

So it would look something like
**bleep** = CALCULATE(sum(fact[value],all(date),filter(date,date[date]<=max(date[date]&&date[year]=year(now()))

The problem your having is your slicers are eliminating the data so your current measure for calculating the **bleep** will return null so nothing is displayed the measure based on the dates from the date table will return the results you require and you let the filter context of the PowerBI engine do the work an you don’t need to deal with the secondary table or the complexities of earlier. (Which is awesome that you figured out I still don’t have my head fully around that. )
Frequent Visitor

## Re: Visual Filter for Cumulative Sum Issue

Community Support Team

## Re: Visual Filter for Cumulative Sum Issue

Hi @Nicklancer,

It seems that you want to have a visual filter with cumulative Sum?

Could you share a screenshot of your visual filter setting?

Actually, if you have a visual filter for cumulative sum, it will show the values match the filter condition.

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Frequent Visitor

## Re: Visual Filter for Cumulative Sum Issue

Hi @v-piga-msft,

I used a donut chart based on the category. So for example, when no category is applied, it shows this:

When I choose a category, say for category A:

Now obviously this looks fine since this constitutes most of the values, however the cumulative line is still not right, as it still shows the total, not total by category.

This becomes ugly when I apply to Category C:

My slicer looks like this:

Hope my explanation is clear enough.

Regards,

Nicholas Hiew

Frequent Visitor