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
Anonymous
Not applicable

Re-filter a table by a column other than the one selected in a slicer visual

I am trying to visualise pharamceutical market share data. I want the user to select a drug from a slicer visual and based on their selection, determine the amount of packs sold for the selected product and all that products' competitors. A unique code determines whether two drugs are competitors. My data looks as follows:

 

Script Table.PNG

 

 

 

 I have placed the 'Product Name_medprax' field in the slicer. I want the model to sum the 'Quantity' field for all products with the same 'Medprax Generic Code' as the product selected in the slicer but not excluding the product selected in the slicer. The problem is when the user selects a product in the slicer the table is filtered by that product. I now need to remove that filter and return all rows where 'Medprax Generic Code' of the product selected in the slicer is equal. I have tired the following DAX code but it is not working:

  

Test = CALCULATE(
     SUM('Adcock Scripts Fact'[Quantity]);
     FILTER(
          ALL('Adcock Scripts Fact');
          'Adcock Scripts Fact'[Medprax Generic Code] = SELECTEDVALUE('Adcock Scripts Fact'[Medprax Generic Code])
     )
)

  

I am using the ALL function within the filter expression to remove the outer filter applied by the slicer, but this doesnt seem to be working. For instance if I select the 'SOLPHYLLEX' product I get the following result:

Solphyllex.PNG

 

 

The green bar is the sum of quantity for just 'SOLPHYLLEX', the black is for SOLPHYLEX and its competitors. Problem is I want the black bar to be split out by 'SOLPHYLLEX' , Product A, Product B etc.

 

Thanks for your help

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi Paul_PowerBI,

 

You said "I have placed the 'Product Name_medprax' field in the slicer. ", you should place field "Medprax Generic Code" instead and then the measure you have created can work.

 

Regards,

Jimmy Tao

View solution in original post

1 REPLY 1
v-yuta-msft
Community Support
Community Support

Hi Paul_PowerBI,

 

You said "I have placed the 'Product Name_medprax' field in the slicer. ", you should place field "Medprax Generic Code" instead and then the measure you have created can work.

 

Regards,

Jimmy Tao

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.