'Power BI Visual Running Total adds up

My Sales per Month visual looks like the first part of the picture.

To show the running total of transactions I use this Measure:

Sum Sales Running Total = 
CALCULATE(
    COUNTROWS(SalesTable),
    FILTER(
        ALLSELECTED(SalesTable),
        SalesTable[CreatedOn] <= MAX(SalesTable[CreatedOn])
    )
)



If I choose only one year by slicer I get a correct visual for the running total. As you can see on the picture.

But if I choose multiple years by slicer for the running total visual, the visual adds all the data up instead of overlapping the graphs. See the lower part of the picture.
enter image description here

The correct sum of transactions is marced green and the wrong sum is marced red.

How can i prevent the visual form summing up the running totals in the visual?



Solution 1:[1]

Hi This behavior is happening because of the group by. modify the measures are below.

Count of Booths Running Total = 
CALCULATE(
    COUNTROWS(dlg_V_Booth_per_Event),
    FILTER(
        ALLSELECTED(dlg_V_Booth_per_Event),
        dlg_V_Booth_per_Event[CreatedOn] <= MAX(dlg_V_Booth_per_Event[CreatedOn]) 
        && dlg_V_Booth_per_Event[RunningMonth] <= MAX(dlg_V_Booth_per_Event[RunningMonth]) 
        && dlg_V_Booth_per_Event[EventName] = max(dlg_V_Booth_per_Event[EventName])
    )
)

Sum of Booth Space Running Total = 
CALCULATE(
    SUM(dlg_V_Booth_per_Event[BoothSpace]),
    FILTER(
        ALL(dlg_V_Booth_per_Event),
        dlg_V_Booth_per_Event[CreatedOn] <= MAX(dlg_V_Booth_per_Event[CreatedOn])
        && dlg_V_Booth_per_Event[RunningMonth] <= MAX(dlg_V_Booth_per_Event[RunningMonth]) 
        && dlg_V_Booth_per_Event[EventName] = max(dlg_V_Booth_per_Event[EventName])
    )
)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AmilaMGunawardana