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
srikumarv
Regular Visitor

Slicing charts based on selected and unselected values

Hi,

 

 I have two charts depicting information from same table. I also have a slicer for these charts. I want the charts to reflect data one based on the selected value in slicer and other chart to display data for all values apart from the one selected.

 

I have not been able to understand what Dax function to apply here but assume the logic would be to first the value selected which i can get as follows and have used 

AcitivitySelected = If ( HasOneValue(BROKER_LINK_ACTIVITY[ACTIVITY]) , Values (BROKER_LINK_ACTIVITY[ACTIVITY]) )

 

But not how to i apply this selected value and all other values apart from this selected value to the below two charts

 

Charts with Filter.JPG

 

 

Slicer value selected

Filter.JPG

1 ACCEPTED SOLUTION
DoubleJ
Solution Supplier
Solution Supplier

Hi That's an interesting issue and I hope I understand your request correctly.... To make this happen you need a filter that does not directly depend on the table you are filtering.

 

I setup a sample with a table containg of 3 types of activities and some values:

 

01.PNG

 

 

  1. Create a new table that consists of the unique Activity entries, I named it "ActivityFilter"

    02.PNG

    ActivityFilter = SUMMARIZE(Activity,Activity[Activity])
    You will use this table for your slicer. Do not link it to your main Activity table!

  2. Create a Measure "SelectedActivity" that determines which Activity has been selected:
    SelectedActivity = IF(
        HASONEFILTER(ActivityFilter[Activity]),
        VALUES(ActivityFilter[Activity]),
        BLANK()) 
  3.  Create a Measure "IsSelectedActivity"
    IsSelectedActivity = IF(
    	HASONEFILTER(Activity[Activity]), 
    		IF(VALUES(Activity[Activity]) = [SelectedActivity],
    			"Yes",
    			"No")
    		,"No")
  4. Create your slicer containing the values from the "ActivityFilter" table
  5. Create your visuals, in my case 2 tables
  6. For the first visual put a filter on the visual level where using "IsSelectedActivity" = "Yes"
  7. Do the same for the second visual, but with the value "No"

In my sample this results to this

03.PNG

 

I hope this helps

JJ

 

View solution in original post

6 REPLIES 6
DoubleJ
Solution Supplier
Solution Supplier

Hi That's an interesting issue and I hope I understand your request correctly.... To make this happen you need a filter that does not directly depend on the table you are filtering.

 

I setup a sample with a table containg of 3 types of activities and some values:

 

01.PNG

 

 

  1. Create a new table that consists of the unique Activity entries, I named it "ActivityFilter"

    02.PNG

    ActivityFilter = SUMMARIZE(Activity,Activity[Activity])
    You will use this table for your slicer. Do not link it to your main Activity table!

  2. Create a Measure "SelectedActivity" that determines which Activity has been selected:
    SelectedActivity = IF(
        HASONEFILTER(ActivityFilter[Activity]),
        VALUES(ActivityFilter[Activity]),
        BLANK()) 
  3.  Create a Measure "IsSelectedActivity"
    IsSelectedActivity = IF(
    	HASONEFILTER(Activity[Activity]), 
    		IF(VALUES(Activity[Activity]) = [SelectedActivity],
    			"Yes",
    			"No")
    		,"No")
  4. Create your slicer containing the values from the "ActivityFilter" table
  5. Create your visuals, in my case 2 tables
  6. For the first visual put a filter on the visual level where using "IsSelectedActivity" = "Yes"
  7. Do the same for the second visual, but with the value "No"

In my sample this results to this

03.PNG

 

I hope this helps

JJ

 

meid
Frequent Visitor

Hello,

 

I have the same issue. I tried @DoubleJ 's solution unfortunately it's not working for me. The card displays the slicer selection but the visuals do not show anything.  Can anyone help me?

In addition, I have trouble understanding how Power BI will filter the Activity table based on a slicer on ActivityFilter if both tables are not linked.

 

Thanks 

Hi,

 

This just works perfectly fine. 

 

I was trying to apply this to charts and summary Multi Card visual on the same page to show summary statistics of the same information it does not work. When i add the Activity and isSelectedActivity fields on the Visual Filter only it does not work for MultiRow card but works perfectly fine for Clusterd Column Chart.

 

I need to display the Activity and IsSelectedAcitivity in the card to get the correct values. 

 

Appreciate your help. You solution works absoultely fine though for the problem i posted. This is just an extension of it

 

 

 

Glad I could help!

 

Feel free  to mark my answer as solution, I would appreciate that 🙂

 

Hi ,

 

Would be able to tell me the problem regarding the issue i am facing for muti row card. Thanks

@srikumarv this issue is a toughie! PowerBI measures are scalar so this method only works for a sinlge selection. I have tried a bunch of work arounds with no luck. If anyone else has an idea or solution it would be much appreciated!

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.