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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
MarkPBI
Frequent Visitor

Why is the data type of this measure different between these two IF statements?

So I'm having trouble getting the resulting DAX Measure return as a Text data type. For some reason it defaults to a Whole Number.

Matrix Background Color =
VAR MaxVal = MAX(Matrix_Desc[Grouping Order])
VAR ColorToReturn = IF(MaxVal==1,"#000000","#FFFFFF")
RETURN IFERROR(ColorToReturn,"#000000")

 

 

Screenshot:

MarkPBI_1-1696761873005.png

 

I'm trying to dynamically set the background color of a matrix using this measure. But it won't allow me to select this measure because it's not  "Text" value.
 
This however, does work (but then it's not dynamic):
Matrix Background Color =
VAR MaxVal = MAX(Matrix_Desc[Grouping Order])
VAR ColorToReturn = IF(TRUE,"#000000","#FFFFFF")
RETURN IFERROR(ColorToReturn,"#000000")

Screenshot:

 MarkPBI_0-1696761823463.png

For some reason using a conditional statement in the IF part of the DAX leads to different result data types??

 

1 ACCEPTED SOLUTION
MarkPBI
Frequent Visitor

I was able to resolve this by changing the "Grouping Order" column that I was taking the MAX from. Apparently this value was a Text value, which was probably leading to an error when taking the MAX and comparing it to a whole number. Changing this column to a a Whole Number ensured that I was able to use the measure as a variable in conditional formatting to set the color.

View solution in original post

1 REPLY 1
MarkPBI
Frequent Visitor

I was able to resolve this by changing the "Grouping Order" column that I was taking the MAX from. Apparently this value was a Text value, which was probably leading to an error when taking the MAX and comparing it to a whole number. Changing this column to a a Whole Number ensured that I was able to use the measure as a variable in conditional formatting to set the color.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors