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

Need help modifying DAX formula for conditional formatting

Hello,

I am using the following formula to get the following result.

However, I need this logic:

 

If the value of "name" at index 2 is different from the value of "name"at index 1, then change color of "name" at index 2,
If the value of "name" at index 3 is different from the value of "name"at index 2, then change color of "name" at index 3,
If the value of "name" at index 4 is different from the value of "name"at index 3, then change color of "name" at index 4.

 

image.png

 

So if "def" is different from "abc" above it, highlight it. But don't highlight the "def" that come after it since they are not different from the value above them. I hope that makes sense.

Pls help me modify/simplify the formula to achieve that.

 

1 ACCEPTED SOLUTION
ChandeepChhabra
Impactful Individual
Impactful Individual

@Anonymous 

  1. Please add a column for a serial number starting with 1 in your data. That can be done using Power Query >> Add Column Tab >> Index >> from 1
  2. Then write the following measure

 

Measure = 
SUMX(
    Data,
    (COUNTROWS(
        FILTER(
            ALL(Data),
            Data[Name]=EARLIER(Data[Name])&&
            Data[Sno]<=MAX(Data[Sno])
            )
        )=1
    )*1
)

Now use conditional formatting to highlight the font based on the measure.

Here is how the result looks like

Capture.PNG

I am hoping this is what you are expecting. You can download the Power BI file here

 

thanks

 

View solution in original post

1 REPLY 1
ChandeepChhabra
Impactful Individual
Impactful Individual

@Anonymous 

  1. Please add a column for a serial number starting with 1 in your data. That can be done using Power Query >> Add Column Tab >> Index >> from 1
  2. Then write the following measure

 

Measure = 
SUMX(
    Data,
    (COUNTROWS(
        FILTER(
            ALL(Data),
            Data[Name]=EARLIER(Data[Name])&&
            Data[Sno]<=MAX(Data[Sno])
            )
        )=1
    )*1
)

Now use conditional formatting to highlight the font based on the measure.

Here is how the result looks like

Capture.PNG

I am hoping this is what you are expecting. You can download the Power BI file here

 

thanks

 

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.