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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Sharmi_28
Helper I
Helper I

Apply background colour to card using single Measure

I have table with 7 columns

Sharmi_28_0-1717074228931.png

I am using New card visual

Sharmi_28_1-1717074291294.png

I want to apply background colour using single Measure
If SUM(Table[1]) > 1 , "Green", "Red"
If SUM(Table[2]) > 1 , "Green", "Red"
If SUM(Table[3]) > 1 , "Green", "Red"
If SUM(Table[4]) > 1 , "Green", "Red"
If SUM(Table[5]) > 1 , "Green", "Red"
If SUM(Table[6]) > 1 , "Green", "Red"
If SUM(Table[7]) > 1 , "Green", "Red"

1 ACCEPTED SOLUTION
Alex87
Super User
Super User

yes, CF on background using only one measure as in your request:

CF_Background = 
SWITCH(
    TRUE(),
    SUM(Test[Value]) > 1, "Green",
    "Red"
)

I did change the structure in Power Query as well, though, I unpivoted the data 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjVR0lEyNQMSBkBsZg5imZlCuUDJ2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"1" = _t, #"2" = _t, #"3" = _t, #"4" = _t, #"5" = _t, #"6" = _t, #"7" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"1", Int64.Type}, {"2", Int64.Type}, {"3", Int64.Type}, {"4", Int64.Type}, {"5", Int64.Type}, {"6", Int64.Type}, {"7", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value")
in
    #"Unpivoted Columns"

so that it looks like this:

Alex87_0-1717140333129.png

I then used the Matric visual, swithched in the option pane the values to rows, applied the CF on text and background

Alex87_1-1717140417816.png

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Alex87
Super User
Super User

yes, CF on background using only one measure as in your request:

CF_Background = 
SWITCH(
    TRUE(),
    SUM(Test[Value]) > 1, "Green",
    "Red"
)

I did change the structure in Power Query as well, though, I unpivoted the data 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjVR0lEyNQMSBkBsZg5imZlCuUDJ2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"1" = _t, #"2" = _t, #"3" = _t, #"4" = _t, #"5" = _t, #"6" = _t, #"7" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"1", Int64.Type}, {"2", Int64.Type}, {"3", Int64.Type}, {"4", Int64.Type}, {"5", Int64.Type}, {"6", Int64.Type}, {"7", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value")
in
    #"Unpivoted Columns"

so that it looks like this:

Alex87_0-1717140333129.png

I then used the Matric visual, swithched in the option pane the values to rows, applied the CF on text and background

Alex87_1-1717140417816.png

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!




@Alex87Thanks a lot

Sharmi_28
Helper I
Helper I

@Alex87 
Thanks you.
Did you apply background colour using measure?

Alex87
Super User
Super User

the closest I can get is using a matrix. 

Alex87_0-1717081662042.png

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!




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