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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
caiying100126
Frequent Visitor

how to highlight the duplicate cells in Power BI table in Desktop

Hi all, I created a table in Power bi desktop, I want to highlight duplicate values in some columns and fill in the background color. Here I want to highlight  "Material","Description","Vendor name" and "Plant" columns.Annotation 2020-02-25 153327.png

 
 
1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @caiying100126 

 

First create a measure to calculate the row count based on your criteria.

Row Count =
//returns 0 if there's no duplicate, otherwise 1
IF (
    CALCULATE (
        COUNTROWS ( 'Table' ),
        ALLEXCEPT ( 'Table', 'Table'[Column1], 'Table'[Column2], 'Table'[Column3] )
    ) = 1,
    0,
    1

Add the columns to a table. 

In fields in visualizations pane,

  • click the arrow down next to the field name then click Conditional Formatting then Background Color.
  • Select Rules from Format by
  • Search the newly created measure in Based on field.
  • Select is then enter 1 into the value field and then select Number. Choose the desired color.

Only those with 1 Row Count will be highlighted. 

Note: Conditional formatting is to be done for each field.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @caiying100126,

Any availed columns that can be used as index? If not I'd like to suggest you add it in query editor.
Then you can try to use the following measure formula to calculate row count and return color and use on conditional formatting features to highlight specific rows.

Measure =
VAR currIndex =
    MAX ( Table[Index] )
VAR currItem =
    SELECTEDVALUE ( Table[Column] )
VAR dc =
    COUNTROWS (
        FILTER ( ALLSELECTED ( Table ), [Column] = currItem && [Index] < currIndex )
    )
RETURN
    IF ( dc > 1, "Red", "Black" )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
danextian
Super User
Super User

Hi @caiying100126 

 

First create a measure to calculate the row count based on your criteria.

Row Count =
//returns 0 if there's no duplicate, otherwise 1
IF (
    CALCULATE (
        COUNTROWS ( 'Table' ),
        ALLEXCEPT ( 'Table', 'Table'[Column1], 'Table'[Column2], 'Table'[Column3] )
    ) = 1,
    0,
    1

Add the columns to a table. 

In fields in visualizations pane,

  • click the arrow down next to the field name then click Conditional Formatting then Background Color.
  • Select Rules from Format by
  • Search the newly created measure in Based on field.
  • Select is then enter 1 into the value field and then select Number. Choose the desired color.

Only those with 1 Row Count will be highlighted. 

Note: Conditional formatting is to be done for each field.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Is this "create a Measure" or "create a Column"?

It's not clear sorry. I think you mean create a Column / New Column

amitchandak
Super User
Super User

Create a measure like this. You have to do it for each column.

Color sales = if(countrown(Table)>1,"red","green")

 

Go to conditional formatting. Based on font or background choose advance control. There choose the option of field and use this measure

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Also refer: https://www.mssqltips.com/sqlservertip/6265/power-bi-conditional-formatting-for-matrix-and-table-vis...

Refer to section: Power BI Field Value Conditional Formatting

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors