Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Sebastiaan99
Frequent Visitor

Measure that keeps one filter while removing another filter both on the same table

Hi

I need some help with a DAX measure that removes one filter while keeping another filter both on the same table.

 

The datamodel is about 6 companies each having multiple locations in different municpalities. And each location has a particular capacity. The size of an organisation is the sum of the capacity of all its locations.

 

In my report I have a dynamic ranking, showing the Top 5 or Top 3 companies in size, depending on whether the user has selected a particular municpality or not (Top 5 when no municipalities are selected and the entire country is shown and Top 3 when one or more municpalities are selected).

 

Therefore the Organisations table is filtered in two ways:
1. Ranking within Top 5 or within Top 3
2. The selected municpalities in the slicer

 

I would like to calculate the marketshare in the selected area (either one or more municipalities or the entire country when no municipalities are selected).

 

Therefore I need to remove the filter that determines to show or hide a particular organisation in the Top N Bar chart. And at the same time I need to keep the filter resulting from the selected municpalities, in order to divide the capacity of the organisation in the selected area by the entire capacity in the selected area.

 

I tried with ALL, REMOVEFILTER and KEEPFILTER, but I cannot figure out how to keep one filter and remove the other at the same time on the same table. And the REMOVEFILTER should point to a measure that determines whether to show an organisation with a particular ranking or not. But REMOVEFILTER accepts only columns. 

 

Any help is appreciated.

 

Current DAX measure (that doesn't work properly):
Market_share =
VAR Grand_total_capacity_selectedarea =
       SUMX (
                 FILTER (ALL('Locations'),
                             'Locations'[Location_type] = "A") ,
                             'Locations'[Capacity]
                 )
VAR Company_capacity = [Sum_of_Capacity]
RETURN DIVIDE (Company_capacity, Grand_total_capacity_selectedarea, "")

 

Other measures:

Show company =
VAR N =
            IF ( ISFILTERED ( Municipalities[Name] ) = TRUE, 3, 5 )
VAR Show_indicator =
        IF (
             RANKX (
                       ALL ( Companies ),
                      [Sum_of_Capacity]
             ) <= N,
             1,
             0
         )
RETURN
Show_indicator

 

 

 

Schermafbeelding 2021-10-27 om 00.29.03.jpg

 

Schermafbeelding 2021-10-27 om 00.37.33.jpg

1 REPLY 1
wdx223_Daniel
Super User
Super User

try this

Market_share =
VAR Grand_total_capacity_selectedarea =
       CACULATE (

                          SUM('Locations'[Capacity]),

                          ALLEXCEPT('Locations',‘Municipalities'[Name]),

                          'Locations'[Location_type] = "A"

                         )
VAR Company_capacity = [Sum_of_Capacity]
RETURN DIVIDE (Company_capacity, Grand_total_capacity_selectedarea, "")

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors