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
Reetz
Helper II
Helper II

Error handling with DAX

Silly question, but Is there a way to write a DAX formula to show a message  instead of the error box?  I've tried iferror, but I still get this error box.  I'd like to display "0%" or "value not available" instead.Capture.PNG

 

Thanks!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Use the HASONEVALUE or HASONEFILTER function to discover whether one, no or more values have been selected and build a conditional logic to display what you want in each case.

Best
D

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

I think there is also ISERROR but it suffers the same limitations.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

Well, it depends on the error if iferror can catch it or not. What is the error you are getting? If it is trying to compare different data types, that is one of the errors it doesn't catch but I created a work-a-round for it somewhere on this community. It was regarding strict and loose comparisons.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thanks for the quick reply!  I am getting a "calculation error in measure: A table of multiple values was supplied where a single value was expected." 

 

My table has a column with 2 values, "Pre-implementation" and "Post-implementation".  My measure calculates totals based on these values.  I also have a slicer for these values.  The totals are accurate if either Pre or Post implementation is chosen in the slicer but I get the error when both are chosen.

Anonymous
Not applicable

Use the HASONEVALUE or HASONEFILTER function to discover whether one, no or more values have been selected and build a conditional logic to display what you want in each case.

Best
D

@Reetz So what should happen if both are chosen? You can check for this condition by using HASONEVALUE and avoid the error.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

If both are chosen, I'm trying to show "Pre/Post Implementation" and the total of everything.

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.