Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
I am using this Dax statement in a columnto return a text value based on a decimal but it always returns the false value of nothing. Where have I gone wrong?
Rating2 = SWITCH( TRUE(), [Total Score] < 6, "No change", [Total Score] >= 6 && [Total Score] < 10, "Low", [Total Score] >= 11 && [Total Score] < 15, "Medium", [Total Score] >= 16 && [Total Score] < 20, "Low", "" )
Solved! Go to Solution.
I found the issue, the measure and column will only work on whole numbers not decimals.
I found the issue, the measure and column will only work on whole numbers not decimals.
Hi @Blaired79
For your question, here is the approach I provide:
Here's some dummy data
"Table"
If you are creating a calculated column, your code will work.
Column Rating2 =
SWITCH(
TRUE(),
[Total Score] < 6, "No change",
[Total Score] >= 6 && [Total Score] < 10, "Low",
[Total Score] >= 11 && [Total Score] < 15, "Medium",
[Total Score] >= 16 && [Total Score] < 20, "Low",
""
)
So I'm assuming if you create a measure.
Create a measure. Try the following code:
Measure Rating2 = var _score = SELECTEDVALUE('Table'[Total Score])
RETURN SWITCH(
TRUE(),
_score < 6, "No change",
_score >= 6 && _score < 10, "Low",
_score >= 11 && _score < 15, "Medium",
_score >= 16 && _score < 20, "Low",
" "
)
Here is the result.
If you still have problems, it is best to provide the pbix file and be careful to delete sensitive data.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The DAX statement is working perfectly fine. I have attached the sample below.
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
110 | |
99 | |
93 | |
88 | |
70 |
User | Count |
---|---|
166 | |
133 | |
129 | |
102 | |
98 |