Forum Discussion
Dax formula does not show up values, only zero
Hii RGummels
Your measure returns 0 because you are comparing columns directly to text inside a measure, which has no row context. As a result, expressions like Column = "Tier 2" always evaluate to FALSE. To fix this, wrap each column in SELECTEDVALUE() (when one value is expected in the visual) or use CALCULATE with COUNTROWS() to evaluate the condition in filter context. Once the comparison is done in the correct context, the measure will return 1 where “Tier 2” exists instead of always returning zero.
Hey RGummels ,
Are you creating a calculated column based on other columns (or is it a measure based on other measures)? The confusion is because it seems you are creating a calc column but the referencing of other columns is more of a pattern we use for measures. If you are indeed creating a calculated column, it just seems that none of those columns have 'Tier 2'. Please make sure there is no whitespace in those columns or incosistent formatting, you could use TRIM, CLEAN and UPPER/LOWER to make sure this problem is not interfering.
Also, the condition for Tier1 seems redundant as you have not used it later (I am assuming this is just a variable during the testing phase).
Hope it helps! But if it does not, please drop a sample of your dataset (sanitized copy without sensitive data and representative of your problem/data diversity).
6 Replies
- mdaatifraza5556Super User
Hi RGummels
Could you please try the below DAX ?
1. If you are creating a measureIs_Tier2_Only =
VAR T2 = "Tier 2"VAR HasTier2 =
SELECTEDVALUE('YourTable'[UDFPSEInjuryIlln__c2c4472af62141fdaa858a3432b95be8]) = T2 ||
SELECTEDVALUE('YourTable'[UDFPSEReleaseofM__6e022d1143054d3cb79b9993100cee1b]) = T2 ||
SELECTEDVALUE('YourTable'[UDFPSEOfficalCom__73fa9b36b0674c60aca02230540bea0a]) = T2 ||
SELECTEDVALUE('YourTable'[UDFPSEFireOrExpl__ae02f986f8ed40b7b2d3e44cbcf86990]) = T2 ||
SELECTEDVALUE('YourTable'[UDFPSEPressureRe__83d6c613dc9945b29abc0b9fc1b54522]) = T2RETURN IF(HasTier2, 1, 0)
2. If you are creating calculated column
Is_Tier2_Only =
VAR T2 = "Tier 2"
RETURN
IF(
'YourTable'[UDFPSEInjuryIlln__c2c4472af62141fdaa858a3432b95be8] = T2 ||
'YourTable'[UDFPSEReleaseofM__6e022d1143054d3cb79b9993100cee1b] = T2 ||
'YourTable'[UDFPSEOfficalCom__73fa9b36b0674c60aca02230540bea0a] = T2 ||
'YourTable'[UDFPSEFireOrExpl__ae02f986f8ed40b7b2d3e44cbcf86990] = T2 ||
'YourTable'[UDFPSEPressureRe__83d6c613dc9945b29abc0b9fc1b54522] = T2,
1,
0
)IF this answers your questions, kindly accept it as a solution and give kudos.
- danextianSuper User
Hi RGummels
You are comparing a fixed constant to a scalar value returned by a measure, where that measure’s result is not truly constant - it can change based on what fields or dimensions are added to the visual, since those combinations of fields affect how the measure is calculated.
- v-menakakotaCommunity Support
Hi RGummels ,
Thanks for reaching out to the Microsoft fabric community forum.
I would also take a moment to thank danextian , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you .
Best Regards,
Community Support Team- v-menakakotaCommunity Support
Hi RGummels ,
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you .
Best Regards,
Community Support Team
- rohit1991Super User
Hii RGummels
Your measure returns 0 because you are comparing columns directly to text inside a measure, which has no row context. As a result, expressions like Column = "Tier 2" always evaluate to FALSE. To fix this, wrap each column in SELECTEDVALUE() (when one value is expected in the visual) or use CALCULATE with COUNTROWS() to evaluate the condition in filter context. Once the comparison is done in the correct context, the measure will return 1 where “Tier 2” exists instead of always returning zero.
- alish_bSuper User
Hey RGummels ,
Are you creating a calculated column based on other columns (or is it a measure based on other measures)? The confusion is because it seems you are creating a calc column but the referencing of other columns is more of a pattern we use for measures. If you are indeed creating a calculated column, it just seems that none of those columns have 'Tier 2'. Please make sure there is no whitespace in those columns or incosistent formatting, you could use TRIM, CLEAN and UPPER/LOWER to make sure this problem is not interfering.
Also, the condition for Tier1 seems redundant as you have not used it later (I am assuming this is just a variable during the testing phase).
Hope it helps! But if it does not, please drop a sample of your dataset (sanitized copy without sensitive data and representative of your problem/data diversity).