Forum Discussion

n00b_90's avatar
n00b_90
Frequent Visitor
7 years ago

Conditionally format bar chart by selected value in slicer - if isfiltered

 

Hi Community! 

 

I am trying to highlight a bar when the element is selected in the slicer. This i how I want it to look. 

 

 

 

I have created a simple measure: 



Measure = if(ISFILTERED(Table1[Namn]);1;0)


The measure works and checkes if the value is selected in the slicer or not.



 



Once i try to add the measure in the conditional formatting for the bar chart, it does not work. Any clue to why? It just changes the bars to a red color as if an element was selected in the slicer.



I am fearly new to POWER BI and DAX, so there might be something I am overlooking.

 

 

 

 

 

 

 

4 Replies

  • v-xuding-msft's avatar
    v-xuding-msft
    Icon for Community Support rankCommunity Support

    Hi n00b_90 ,

     

    By my test,  you need to  modify the measure. The following measure you can have a try.

     

    Measure  = var a = SELECTEDVALUE(Table2[Namn]) return IF(a in VALUES(Table1[Namn]),1,0)

     

     

    Best Regards,

    Xue Ding

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • n00b_90's avatar
      n00b_90
      Frequent Visitor

      Hi, 

       

      Unfortunetly, I only have one table to base the code on. I can get the code to work with two tables as well, but that wont be an option for me since the data is connected through live connection. 

       
      Any idea how i can modify the code in order for it to work on one table?
  • v-xuding-msft's avatar
    v-xuding-msft
    Icon for Community Support rankCommunity Support

    Hi n00b_90 ,

    There is no way to implement the result you expected in one table directly.  When you use the column from the same as  table to filter, it will only  display the bar selected , not all the bars . Maybe  you could try  to create a new table in the data source , then to implement highlight in Power BI.

     

    Best Regards,

    Xue Ding

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • n00b_90's avatar
      n00b_90
      Frequent Visitor

      ok, so i have an ID in both the fact and Dim but the name (which is used as a filter) is only in the dim-table. Is there any way to make the code work with that information? Mayble like, when the name is filtered it looksup the ID value or something like that? 

       

      kind regards, 

      M