Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I am writing a DAX formula to return a text result ("NED", which means "not enough data") if a quantity on hand of an item is less than a certain amount. However, if it is true, then it should return the numerical data. I don't care if the data is actually stored as a number or a string, however, as I am just displaying it in a card in Power BI desktop. Though the data IS numerical in previous calculations (hence why this final calculation is called "Calc4_qOH"). Here's my query:
EstQtyOH = IF(InvAnalytics[Calc4_qOH] < 2, "NED", InvAnalytics[Calc4_qOH])
I receive the error "Expressions that yield variant data-type cannot be used to define calculated columns."
If I change "NED" to a number, the IF statement works. I tried SWITCH as well, but didn't get any further than if I used IF. Am I doing something wrong and my request is possible, or is my request impossible for DAX? Again, I am still learning DAX as I go. Many thanks in advance!
- Derek
Solved! Go to Solution.
Hey,
try this
IF( AND( InvAnalytics[Calc4_qOH] >= 2 ,NOT ISBLANK(InvAnalytics[Calc4_qOH]) ) ,FORMAT(InvAnalytics[Calc4_qOH], "#.##") , "NED" )
this could be an alternative
IF( AND( InvAnalytics[Calc4_qOH] >= 2 ,InvAnalytics[Calc4_qOH] <> "" ) ,FORMAT(InvAnalytics[Calc4_qOH], "#.##") , "NED" )
BLANK() returns a BLANK() meaning NULL value whereas ISBLANK(...) checks if a column reference is empty
Regards
Tom
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |