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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Anonymous
Not applicable

Creating calculated column with blanks and number comparison

I have a column of "Target" values with some blank rows and a measure calculation "Measure1" based off other columns. I want to create a new column "Value Color" that compares the Measure1 to the Target values and then gives a color based off comparison.

But the Target  has blank rows, so if the Target is blank, then I don't want a color for "Value Color".

I want the dax calculation to be

  • if Target is blank, then color is none
  • if Measure1 > Target (Target is not blank), then "#31991a"
  • if Measure1 <= Target (Target not blank), then "#ff4a4a"
ValueColor =
IF (
    ISBLANK ( 'Table'[Target] ),
    BLANK (),
    IF (
        [Measure1] > 'Table'[Target],
        "#31991a",
        IF ( [Measure1] <= 'Table'[Target], "#ff4a4a" )
    )
)
1 ACCEPTED SOLUTION
vanessafvg
Super User
Super User

better to do a switch statement ie.

ValueColor =
SWITCH (
TRUE (),
ISBLANK ( 'Table'[Target] ), BLANK (),
[Measure1] > SUM ( 'Table'[Target] ), "#31991a",
[Measure1] <= SUM ( 'Table'[Target] ), "#ff4a4a",
BLANK ()
)





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

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

vanessafvg
Super User
Super User

better to do a switch statement ie.

ValueColor =
SWITCH (
TRUE (),
ISBLANK ( 'Table'[Target] ), BLANK (),
[Measure1] > SUM ( 'Table'[Target] ), "#31991a",
[Measure1] <= SUM ( 'Table'[Target] ), "#ff4a4a",
BLANK ()
)





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 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 Solution Authors
Top Kudoed Authors