Thursday, April 25, 2024

How to highlight Visual rows based on Slicer Selection in Power BI

How to highlight Visual rows based on Selected values from Slicer in Power BI
Scenario:
Suppose we have a simple data Model as follows:

The Table visual built on this Model as follows:

Now we want to highlight (NOT filtering) the rows on this table, based on the selected values from a Product Name Slicer.

We can achieve this Scenario, by creating a disconnected (NOT related to the Model) table with a list of unique Product Names as shown below:

UniqProducts = ALLNOBLANKROW(ds_Sample[Prod_Name])



Next, by using the following DAX formula, we can identify which Products are selected, and then based on that we can apply the color formatting to highlight.

Highlight Products =
VAR IsFilteredProd = ISFILTERED(UniqProducts[Prod_Name])
VAR vCountProd =
COUNTROWS(
    FILTER( VALUES(ds_Sample[Prod_Name]),
        SELECTEDVALUE(ds_Sample[Prod_Name]) IN VALUES(UniqProducts[Prod_Name])
        )
    )
VAR vFormat = IF(vCountProd>=1, "#00bfa0", BLANK())
VAR vResult = IF(IsFilteredProd=TRUE(), vFormat)
RETURN
vResult

Next, use this formula to apply the conditional formatting for the Cell elements > Series > BG Color for the required columns selected on the visual.



Finally, the result is as follows:

--------------------------------------------------------------------------------------------------------
Thanks, TAMATAM ; Business Intelligence & Analytics Professional
--------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog