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
PrivateAnalytic
Helper IV
Helper IV

Coloring Values Assistance

Hello community!

I have created a matrix and a table on the same tab of a Power BI Report. (See 1st picture below)

PrivateAnalytic_0-1657198130006.png

The table on the left uses conditional columns which I manually inserted into the table. (For example: If the time is 8:00 AM, then 15 staff is then 49, and so on and so fourth). Both visuals are useing the same times. The values in the matrix are using a column called StudentID, and the values are as Count (Distinct).

I was asked to find a way to color the values on the right as follows:

  • If the Value is above the 5 Staff number, then color it Green
  • If the Value is below the 15 Staff number, then color it Red
    • Ex: On January 25, 2022 the value is 30. This value would be Red
  • If Value is in between, then color is Yellow 

Here is an example of the data I am using

TimeDateStudentNameStudentIDCollegeCreditHours15 Staff5 Staff
8:00 AMJanuary 27, 2022Joseph Mann005866Business144951
9:00 AMJanuary 29, 2022John Doe447856Business167779
9:30 AMJanuary 25, 2022Jane Doe555013Law187072
10:00 AMJanuary 25, 2022Ryan Pierce554876Graduate166163
8:00 AMJanuary 26, 2022Jannette Richardson332146Education154951
12:00 PMJanuary 27, 2022Dameon Travis958741Business154547
2:00 PMJanuary 28, 2022Marney Phillips004584Education156365

 

I am not really 100% sure how this would be able to get formatted the way I am being asked. Would this be using Variables in a calculation? I struggle so much with variables and some DAX Functions. I've tried to do drop down on the values and conditionally format, however that really didn't work for my case.

 

I did attempt to do conditional formatting. However with the rules, I am not able to do conditional formatting based on both 15 Staff and 5 Staff. So it is being sort of odd with it because I am trying to compare the Value between both 15 and 5 Staff. Is there some sort of DAX Expression that can maybe be written to compare the value between both 15 and 5 Staff?

PrivateAnalytic_0-1657209760238.png

 

2 ACCEPTED SOLUTIONS
DataInsights
Super User
Super User

@PrivateAnalytic,

 

You can achieve this with a measure that determines the color:

 

Color Measure = 
VAR vCount = [Count StudentID]
VAR v15Staff =
    MAX ( Table1[15 Staff] )
VAR v5Staff =
    MAX ( Table1[5 Staff] )
VAR vResult =
    // use color names or hex codes
    SWITCH ( TRUE, vCount > v5Staff, "Green", vCount < v15Staff, "#E6113C", "Yellow" ) 
RETURN
    vResult

 

Create conditional formatting for the measure [Count StudentID]:

 

DataInsights_0-1657289092183.png

 





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

Proud to be a Super User!




View solution in original post

v-zhangti
Community Support
Community Support

Hi, @PrivateAnalytic 

 

Based on the data you have provided, you can refer to the following methods.

Measure = 
Var N1=DISTINCTCOUNT('Table'[StudentID])
return
SWITCH(TRUE(),
N1>SELECTEDVALUE('Table'[5 Staff]),"Green",
N1<SELECTEDVALUE('Table'[15 Staff]),"Red",
"Yellow")

vzhangti_0-1657625035853.png

vzhangti_1-1657625071288.png

vzhangti_2-1657625091871.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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @PrivateAnalytic 

 

Based on the data you have provided, you can refer to the following methods.

Measure = 
Var N1=DISTINCTCOUNT('Table'[StudentID])
return
SWITCH(TRUE(),
N1>SELECTEDVALUE('Table'[5 Staff]),"Green",
N1<SELECTEDVALUE('Table'[15 Staff]),"Red",
"Yellow")

vzhangti_0-1657625035853.png

vzhangti_1-1657625071288.png

vzhangti_2-1657625091871.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.

DataInsights
Super User
Super User

@PrivateAnalytic,

 

You can achieve this with a measure that determines the color:

 

Color Measure = 
VAR vCount = [Count StudentID]
VAR v15Staff =
    MAX ( Table1[15 Staff] )
VAR v5Staff =
    MAX ( Table1[5 Staff] )
VAR vResult =
    // use color names or hex codes
    SWITCH ( TRUE, vCount > v5Staff, "Green", vCount < v15Staff, "#E6113C", "Yellow" ) 
RETURN
    vResult

 

Create conditional formatting for the measure [Count StudentID]:

 

DataInsights_0-1657289092183.png

 





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

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.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Kudoed Authors