Forum Discussion

Basdo's avatar
Basdo
Frequent Visitor
3 years ago
Solved

Keep Filter Selection within ALLEXCEPT

Hi,

 

I have Data in this format:

 

DateNameSales
01.01.2022A10 €
02.01.2022A10 €
02.01.2022B100 €
03.01.2022A10 €
03.01.2022B100 €
04.01.2022A10 €
04.01.2022B100 €
04.01.2022C

1000 €

 

Now I want to build the running sales total per Name and the user should be able to select more than one names.

My current DAX formula is:

 

Sales running total =
CALCULATE(
    [Sales],
    FILTER(
        ALL(Table), [Date] <= MAX([Date])
    )
)

This is working when all names are selected but not when the user is for example only selecting names A and B as the ALL filter is removing the name filter context completely.

I also tried this formula:

CALCULATE(
    [Sales],
    FILTER(
        ALLEXCEPT(Table, Table[Names]), [Date] <= MAX([Date])
    )
)

But then the totals for each names are calculated separately and the outcome is not a total over all names as wanted.
 
I somehow need to remove the name filter to be able to calculate the totals but in the same time keep the user selection.
How do I do that?

2 Replies

  • lukiz84's avatar
    lukiz84
    Memorable Member

    Don't use ALLEXCEPT, use ALLSELECTED

  • Hi,

    Please check the below picture and the attached pbix file.

    One of ways to achieve this is to use column in the measure, not the whole table.

     

     

     

    Sales running total: =
    CALCULATE (
        [Sales:],
        FILTER ( ALL ( 'Table'[Date] ), 'Table'[Date] <= MAX ( 'Table'[Date] ) )
    )