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,
I have an error in my DAX that I would like to catch and continue. Perhaps you can help.
I have two tables. One is a list of numbers and the other is a number range with a description. Like this:
NumberTable
NumAsInt
3
25
75
DescriptionTable
Desc, StartNum, EndNum
“small”, 0, 33
“medium”,34,75
“large”,75,1000
My DAX is:
NumberDescription =CALCULATE(VALUES(DescriptionTable[Desc]),
FILTER(DescriptionTable,
NumberTable[NumAsInt] >= DescriptionTable[StartNum] && NumberTableNumAsInt] <= DescriptionTable[EndNum]))
The problem is when NumAsInt is 75 two entries from the DescriptionTable are returned and I get an error in the formula. What I would like to do is ingnore that error and return blank for the description. The real problem of course is that I have overlapping ranges in my DescriptionTable but its just not practical to fix that. I played a bit with IF HASONEVALUE but couldn't get that to work.
Thanks,
-Wes
Solved! Go to Solution.
Hi Wes,
From your post it appears that you're creating a calculated column in NumberTable, similar to a Static Segmentation pattern.
To fix your immediate issue, you could replace VALUES with SELECTEDVALUE, which will automatically return blank in the case of multiple matches.
You may want to take a look at Static Segmentation - DAX Patterns for more general discussion of this sort of pattern.
Regards,
Owen
Thanks. That worked.
Hi Wes,
From your post it appears that you're creating a calculated column in NumberTable, similar to a Static Segmentation pattern.
To fix your immediate issue, you could replace VALUES with SELECTEDVALUE, which will automatically return blank in the case of multiple matches.
You may want to take a look at Static Segmentation - DAX Patterns for more general discussion of this sort of pattern.
Regards,
Owen
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 |
---|---|
47 | |
24 | |
20 | |
15 | |
13 |
User | Count |
---|---|
51 | |
46 | |
39 | |
19 | |
19 |