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
cooksteve09
Frequent Visitor

Conditional Formatting using calculated measure

Please help!!

 

What i am after seeing in the "If_Red" column is, if the value has increased on previous week then green, red if decrease and blue if equal, below is an example of my data and my calculated column so far

 

cooksteve09_0-1631539078593.png

 

 

Im not great at writing dax so any help would be greatly appreciated

 

Thanks in advance

Conditional formatting based on % of another column Calculated Column 

 

 

1 ACCEPTED SOLUTION

Please try:

 

Column = 
var current_ = 'Table'[Index]
var next = current_+1
var base_line = MAX('Table'[Index])
var current_value = 'Table'[filled]
var next_value = CALCULATE(SUM('Table'[filled]),FILTER('Table','Table'[Index]=next))
return SWITCH(TRUE(),
'Table'[Index]=base_line,"black",
    current_value>next_value,"green",
    current_value<next_value,"red",
    current_value=next_value,"blue"
    )
    

 

Vlianlmsft_0-1631860625763.png

 

 

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@cooksteve09 Just tweak the condition in the switch function based on your logic and it should work, you can add more conditions as per the business logic, not sure if you are unable to do that basic value condition stuff. You have the ides in the solution, just tweak it.

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@cooksteve09 your last statement should be

 

SWITCH ( TRUE(),
 Current_Value > Previous_Value, "Green",
 Current_Value < Previous_Value, "Red",
 "Blue"
)

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you @parry2k but its not quite right

 

cooksteve09_0-1631543986710.png

Step 2 should be green because its greater then step 3 and step 3 should be blue because its equal to step 4, step 4 should be green because its greater then step 5 and step 5 should be black because thats the base line

 

does that make sense? any idea how i get it to work that way?

Please try:

 

Column = 
var current_ = 'Table'[Index]
var next = current_+1
var base_line = MAX('Table'[Index])
var current_value = 'Table'[filled]
var next_value = CALCULATE(SUM('Table'[filled]),FILTER('Table','Table'[Index]=next))
return SWITCH(TRUE(),
'Table'[Index]=base_line,"black",
    current_value>next_value,"green",
    current_value<next_value,"red",
    current_value=next_value,"blue"
    )
    

 

Vlianlmsft_0-1631860625763.png

 

 

Thank you, this is almost perfect except the baseline is only applying to the largest number of one ID, i need it to apply to each ID's largest Step number....tried several things but i just cant quite get the DAX right

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.