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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Tushar_IG
New Member

Color coding same value with different quarters

Hi 

 

I am trying to create 2 cards with same value and linked them with 2 slicers - (quarter and year) and used edit interaction so, I can compare 2 different qurter and then color code both card visuals on the baises of greater than-red, equals to=yellow and less than-green by dax. But even though cards shows different value color code is appearing for equals only.

 

Tushar_IG_0-1645981716066.png

Dax: 

1st # of Trials = CALCULATE([# of Trials],
FILTER(Date2,
Date2[Year] = SELECTEDVALUE(Date2[Year]) &&
Date2[Quarter] = SELECTEDVALUE(Date2[Quarter])))
 
2nd # of Trials = CALCULATE([# of Trials],
FILTER(Date2,
Date2[Year] = SELECTEDVALUE(Date2[Year]) &&
Date2[Quarter] = SELECTEDVALUE(Date2[Quarter])))
 
1st color = IF([1st # of Trials] > [2nd # of Trials], "Red",
IF([1st # of Trials] = [2nd # of Trials], "Yellow",
IF([1st # of Trials] < [2nd # of Trials], "Green")))
 
2nd color = IF([2nd # of Trials] > [1st # of Trials], "Red",
IF([2nd # of Trials] = [1st # of Trials], "Yellow",
IF([2nd # of Trials] < [1st # of Trials], "Green")))
 
Please assist it's urgent.
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Tushar_IG 

 

You can try the following methods. In order to make the two slicers work separately, a new date table needs to be created.

Table:

Date = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))

Measure:

1st # of Trials = CALCULATE(SUM('Table'[# of Trials]))
2nd # of Trials =
CALCULATE (
    SUM ( 'Table'[# of Trials] ),
    FILTER (
        ALL ( 'Table' ),
        [Year] = SELECTEDVALUE ( 'Date'[Year] )
            && [Quarter] = SELECTEDVALUE ( 'Date'[Quarter] )
    )
)

Measure about the color does not need to be changed. Measure needs to be added to the background color of the card.

1st color = IF([1st # of Trials] > [2nd # of Trials], "Red",
IF([1st # of Trials] = [2nd # of Trials], "Yellow",
IF([1st # of Trials] < [2nd # of Trials], "Green")))
2nd color = IF([2nd # of Trials] > [1st # of Trials], "Red",
IF([2nd # of Trials] = [1st # of Trials], "Yellow",
IF([2nd # of Trials] < [1st # of Trials], "Green")))

vzhangti_2-1646203185936.pngvzhangti_1-1646203136975.pngvzhangti_3-1646203216618.png

Set the background color for the two cards separately, and you can filter the slicer to compare the quarterly values.

vzhangti_4-1646203304258.png

vzhangti_5-1646203426432.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @Tushar_IG 

 

You can try the following methods. In order to make the two slicers work separately, a new date table needs to be created.

Table:

Date = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))

Measure:

1st # of Trials = CALCULATE(SUM('Table'[# of Trials]))
2nd # of Trials =
CALCULATE (
    SUM ( 'Table'[# of Trials] ),
    FILTER (
        ALL ( 'Table' ),
        [Year] = SELECTEDVALUE ( 'Date'[Year] )
            && [Quarter] = SELECTEDVALUE ( 'Date'[Quarter] )
    )
)

Measure about the color does not need to be changed. Measure needs to be added to the background color of the card.

1st color = IF([1st # of Trials] > [2nd # of Trials], "Red",
IF([1st # of Trials] = [2nd # of Trials], "Yellow",
IF([1st # of Trials] < [2nd # of Trials], "Green")))
2nd color = IF([2nd # of Trials] > [1st # of Trials], "Red",
IF([2nd # of Trials] = [1st # of Trials], "Yellow",
IF([2nd # of Trials] < [1st # of Trials], "Green")))

vzhangti_2-1646203185936.pngvzhangti_1-1646203136975.pngvzhangti_3-1646203216618.png

Set the background color for the two cards separately, and you can filter the slicer to compare the quarterly values.

vzhangti_4-1646203304258.png

vzhangti_5-1646203426432.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

VijayP
Super User
Super User

 
Try this formula and use this same conditional formatting for both cards
and see the result
1st color = IF([1st # of Trials] - [2nd # of Trials]<0 "Red",
IF([1st # of Trials] - [2nd # of Trials]=0"Yellow",
IF([1st # of Trials] - [2nd # of Trials]>0"Green")))
 
 
 
 
 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Hi @VijayP,

 

I tried that but didn't work still color coding is yelloow.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.