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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors
Top Kudoed Authors