Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

DAX error catch and continue, filter returns multiple values

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

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

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


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks. That worked.

OwenAuger
Super User
Super User

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


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors