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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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.

Follow on LinkedIn
@ 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.

Follow on LinkedIn
@ 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.


Follow on LinkedIn
@ 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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.