Forum Discussion
DAX
It seems like you're encountering an error in your DAX expression because the MAX() function expects a column of values to return the maximum from, but you're passing a single value, which is not allowed in calculated columns.
To fix this, you can use an IF() statement instead of MAX(). Here's how you can adjust your DAX expression:
Result =
SWITCH(
TRUE(),
Tablename[Final] = "Negative", "Negative",
AND(Tablename[Final] = "Positive", Tablename[Type] = "ABCD"), Tablename[Numeric_Result],
BLANK() // If none of the conditions are met, return blank
)
This DAX expression follows your specified rules:
- If Final is "Negative", the result is "Negative".
- If Final is "Positive" and Type is "ABCD", the result is the value in the Numeric_Result column.
- If none of the conditions are met, it returns blank.
Make sure to replace "Tablename" with the actual name of your table in Power BI. This expression should work in creating the calculated column you desire.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
- KT92 years agoRegular Visitor
Hi 123abc ,
Thank you so much for your response and the clear clarrification. I tried this DAX formula. But it throws an error says that "Function 'switch' does not support comparing values of type True/False with values of type Text. Consider using the VALUE or FORMAT funtion to convert one of the values."
The Number_Result column contains the values like
0.000
1.099
-0.999
67.777