cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LaurieS Frequent Visitor
Frequent Visitor

DAX - Default Filter & ALLEXCEPT

I'm very new in Power BI, and I've written the following DAX and only part of it is working as desired:

 

Total Runs Global =

IF(
[CurrentSelectionsToolType]=[TotalSelectionsToolType],
CALCULATE(sum('pbi sensor_data'[Sensor Runs]),FILTER('pbi sensor_data','pbi sensor_data'[Tool Type]="ABI"),
ALLEXCEPT('pbi luLocations','pbi luLocations'[Region]),
ALLEXCEPT('pbi luLocations','pbi luLocations'[Country]),
ALLEXCEPT('pbi luLocations','pbi luLocations'[Area]),
ALLEXCEPT('pbi luLocations','pbi luLocations'[District])),

CALCULATE(sum('pbi sensor_data'[Sensor Runs]),
ALLEXCEPT('pbi luLocations','pbi luLocations'[Region]),
ALLEXCEPT('pbi luLocations','pbi luLocations'[Country]),
ALLEXCEPT('pbi luLocations','pbi luLocations'[Area]),
ALLEXCEPT('pbi luLocations','pbi luLocations'[District])
))
 

If something is chosen in the tool type slicer, then it behaves as desired and ignores any of the location slicers. If nothing is chosen in the slicer, then it should behave the same way by ignoring any selections in the region, country, etc. slicers but be filtered for tool type ABI. It is filtering for tool type = ABI correctly, but it is reacting to the location slicers when it should be ignoring them. Any guidance would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
LaurieS Frequent Visitor
Frequent Visitor

Re: DAX - Default Filter & ALLEXCEPT

Thank you so much for your prompt reply. I had a colleague helping that solved the issue.

 

His solution: Please check the below measures, instead of using single measure I have separated 'pbi sensor_data'[Tool Type]="ABI" filter into separate measure named ABISensorRuns. Then I used new measure ABISensorRuns in Total Runs Global measure.

 

ABISensorRuns = CALCULATE(

        sum('pbi sensor_data'[Sensor Runs]),

        FILTER('pbi sensor_data','pbi sensor_data'[Tool Type]="ABI"))

 

Total Runs Global =

IF(

    [CurrentSelectionsToolType]=[TotalSelectionsToolType],

     CALCULATE(

        [ABISensorRuns],ALLEXCEPT('pbi luLocations','pbi luLocations'[Region]),

            ALLEXCEPT('pbi luLocations','pbi luLocations'[Country]),ALLEXCEPT('pbi luLocations','pbi luLocations'[Area]),

            ALLEXCEPT('pbi luLocations','pbi luLocations'[District])

      ),

    CALCULATE(sum('pbi sensor_data'[Sensor Runs]),ALLEXCEPT('pbi luLocations','pbi luLocations'[Region]),

            ALLEXCEPT('pbi luLocations','pbi luLocations'[Country]),ALLEXCEPT('pbi luLocations','pbi luLocations'[Area]),

            ALLEXCEPT('pbi luLocations','pbi luLocations'[District])

))

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: DAX - Default Filter & ALLEXCEPT

Hi LaurieS,

Could you please share the sample data and expected result to us? According to your description, my understanding is that you have two rules, one is ignoring all location slicers, another one is setting the default tool type as ABI.

In this scenario, we can use the following DAX query:

Total Runs Global =

IF(

    SELECTEDVALUE('pbi luLocations'[Tool Type])=BLANK(),

    CALCULATE(SUM('pbi luLocations'[Sensor Runs]),FILTER(ALLEXCEPT('pbi luLocations','pbi luLocations'[Other]),'pbi luLocations'[Tool Type] = "ABI")),

    CALCULATE(SUM('pbi luLocations'[Sensor Runs]),ALLEXCEPT('pbi luLocations','pbi luLocations'[Other],'pbi luLocations'[Tool Type])

))

The result will like below:

111.png222.png

Best Regards,

Teige

 

Highlighted
LaurieS Frequent Visitor
Frequent Visitor

Re: DAX - Default Filter & ALLEXCEPT

Thank you so much for your prompt reply. I had a colleague helping that solved the issue.

 

His solution: Please check the below measures, instead of using single measure I have separated 'pbi sensor_data'[Tool Type]="ABI" filter into separate measure named ABISensorRuns. Then I used new measure ABISensorRuns in Total Runs Global measure.

 

ABISensorRuns = CALCULATE(

        sum('pbi sensor_data'[Sensor Runs]),

        FILTER('pbi sensor_data','pbi sensor_data'[Tool Type]="ABI"))

 

Total Runs Global =

IF(

    [CurrentSelectionsToolType]=[TotalSelectionsToolType],

     CALCULATE(

        [ABISensorRuns],ALLEXCEPT('pbi luLocations','pbi luLocations'[Region]),

            ALLEXCEPT('pbi luLocations','pbi luLocations'[Country]),ALLEXCEPT('pbi luLocations','pbi luLocations'[Area]),

            ALLEXCEPT('pbi luLocations','pbi luLocations'[District])

      ),

    CALCULATE(sum('pbi sensor_data'[Sensor Runs]),ALLEXCEPT('pbi luLocations','pbi luLocations'[Region]),

            ALLEXCEPT('pbi luLocations','pbi luLocations'[Country]),ALLEXCEPT('pbi luLocations','pbi luLocations'[Area]),

            ALLEXCEPT('pbi luLocations','pbi luLocations'[District])

))

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 218 members 2,554 guests
Please welcome our newest community members: