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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Iam_Syed
Regular Visitor

When values duplicate then green when unique then Red

Hi Team,

 

I am stuck for creating a calculation but lo luck, please help on this.

 

In this table has Row = Category (Text)

                          Column = Type (Text)

                          Values = sum of sales (Numeric)

I want to show this table values when duplicate then Green color if Unique the Red color.                           

 

Category S1S2S3
Mobile113113114
Laptop113311331134
Desktop221111222211
Furniture110111021101

 

 

Thanks

Syed

2 ACCEPTED SOLUTIONS
FreemanZ
Community Champion
Community Champion

hi @Iam_Syed ,

 

Not sure if i fully get you, supposing you have a data table like:

FreemanZ_0-1771686227098.png

 

try to plot your expected matrix visual and apply conditional formatting for the value field background based field value with a measure like below:

Measure = 
VAR _cat = MAX(data[category])
VAR _type = MAX(data[type])
VAR _table =
    ADDCOLUMNS(
        SUMMARIZE(
            FILTER(
                ALL(data),
                data[category] = _cat && data[type] <> _type
            ),
        data[category], data[type]
        ),
        "Amt",
        CALCULATE(SUM(data[sales]))
    )
VAR _AmtList = SUMMARIZE(_table, [Amt])
VAR _result = IF([SalesAmt] IN _AmtList, "Green", "Red")
RETURN _result

 

it works like:

 

FreemanZ_2-1771686561010.png

View solution in original post

hello @Iam_Syed 

 

for subtotal, just tick either column or row subtotal or both depend on your need.

Irwan_0-1771886920521.png

 

Thank you.

View solution in original post

12 REPLIES 12
v-kpoloju-msft
Community Support
Community Support

Hi @Iam_Syed

Thank you for reaching out to the Microsoft Fabric Community Forum. Also, thanks to @Irwan@techies@FreemanZ,  for those inputs on this thread.

Has your issue been resolved? If the response provided by the community member @Irwan@techies@FreemanZ,  addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.

Thank you for using the Microsoft Community Forum.

Hi @Iam_Syed

Just wanted to follow up. If the shared guidance worked for you, that’s wonderful hopefully it also helps others looking for similar answers. If there’s anything else you'd like to explore or clarify, don’t hesitate to reach out.

Thank you.

techies
Super User
Super User

Hi @Iam_Syed Based on the current logic (see screenshot attached), the subtotal is highlighted green when that category contains duplicate values across types.

 

techies_0-1771872880852.png

Is this the expected behavior?

 

 

Power BI & Microsoft Fabric
PL-300 | DP-600 | DP-700 Certified
FreemanZ
Community Champion
Community Champion

hi @Iam_Syed ,

 

Not sure if i fully get you, supposing you have a data table like:

FreemanZ_0-1771686227098.png

 

try to plot your expected matrix visual and apply conditional formatting for the value field background based field value with a measure like below:

Measure = 
VAR _cat = MAX(data[category])
VAR _type = MAX(data[type])
VAR _table =
    ADDCOLUMNS(
        SUMMARIZE(
            FILTER(
                ALL(data),
                data[category] = _cat && data[type] <> _type
            ),
        data[category], data[type]
        ),
        "Amt",
        CALCULATE(SUM(data[sales]))
    )
VAR _AmtList = SUMMARIZE(_table, [Amt])
VAR _result = IF([SalesAmt] IN _AmtList, "Green", "Red")
RETURN _result

 

it works like:

 

FreemanZ_2-1771686561010.png

Irwan
Super User
Super User

hello @Iam_Syed 

 

please check if this accomodate your need.

Irwan_0-1771541108295.png

1. i assumed your original table looks like the one you screenshot above, then you need to unpivot your table.

Irwan_1-1771541193739.png

2. create a measure for checking the duplicate and coloring

Color Palette =
var _Duplicate =
CALCULATE(
    COUNT('Table'[Category]),
    FILTER(
        ALL('Table'),
        'Table'[Category]=SELECTEDVALUE('Table'[Category])&&
        'Table'[Value]=SELECTEDVALUE('Table'[Value])
    )
)
Return
IF(
    _Duplicate>1,
    "Green",
    "Red"
)

3. create a matrix visual then assign the measure for conditional formating.

Irwan_3-1771541343179.png

4. in conditional formating, choose Field value in Format style then use the measure for the field.

Irwan_4-1771541411219.png

 

Hope this will help.
Thank you.

Hi Irwan,

Thanks for quick reply,

 

When I apply this calculation in my original table, all rows getting green,

 

Color Palette =
var _Duplicate =
CALCULATE(
    COUNT('SDSA047 Sales History Analysis (As Reported) - PBI'[Profit Center]),
    FILTER(
        ALL('SDSA011 High Level Analysis (as Reported) - PBI'),
        'SDSA011 High Level Analysis (as Reported) - PBI'[Profit Center]=SELECTEDVALUE('SDSA011 High Level Analysis (as Reported) - PBI'[Profit Center])&&
        'SDSA011 High Level Analysis (as Reported) - PBI'[INV VAL]=SELECTEDVALUE('SDSA011 High Level Analysis (as Reported) - PBI'[INV VAL])
    )
)
Return
IF(
    _Duplicate>1,
    "Green",
    "Red"
)
 
 
Thanks
Syed

Hello @Iam_Syed 

 

The logic should be fine.

Can you share a screenshot of your result where you said all green?

 

Thank you.

Hi Irwan,

 

Anyways I got the calculation in Copilot where I need to create 3 measures, 

1 Rounded 2 Count of Duplicates 3 Color flag.  thanks you can close this.

 

Iam_Syed_0-1771582357487.png

 

need to show in subtotal

hello @Iam_Syed 

 

i see your result has already good, it shows green for same value while red shows the different value. except the zero and blank value.

 

here i made a little bit changes with some blank and zero value.

- previous (exact same DAX as before), blank and zero show green.

Irwan_0-1771712635001.png

- changes (add more filter). the additional syntax is colored red in DAX below.

Irwan_1-1771712677492.png

Color Palette =
var _Duplicate =
CALCULATE(
    COUNT('Table'[Category]),
    FILTER(
        ALL('Table'),
        'Table'[Category]=SELECTEDVALUE('Table'[Category])&&
        'Table'[Value]=SELECTEDVALUE('Table'[Value])&&
        not (
        'Table'[Value]=0||
        ISBLANK('Table'[Value])
        )
    )
)
Return
IF(
    _Duplicate>1,
  "Green",
    "Red"
)

Hope this will help.
Thank you.

Hi Irwan,

 

We need that 0 values the table it selft will calculate right, if duplicate then Green or If unique the Red. that is fine what we expected,

 

I wanted to show the subtotal as well 

hello @Iam_Syed 

 

for subtotal, just tick either column or row subtotal or both depend on your need.

Irwan_0-1771886920521.png

 

Thank you.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.