cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gaccardo-slb
Advocate II
Advocate II

Why doesn't IFERROR work for PATH errors?

There are several posts on dealing with errors that occur when using the PATH function in DAX.  All of the ones I've seen focus on fixing the data before trying to use PATH.  In my case, I'm using the path to do some LOOKUPVALUE calls to determine other values.  In short, if the PATH fails to find a path for any reason, that's ok.  Given some recent changes in the data, I now get the following error:

The value '1349021' in 'MyTable'[ParentId] must also exist in 'MyTable'[Id]. Please add the missing data and try again.

So I tried the following code to ignore the error:

Parent Path =
  IFERROR (
    PATH (
      [Id],
      [ParentId]
    ),
    ""
  )

My assumption was that IFERROR () would trap the error and allow me to proceed with a blank value.  Why can't errors in the PATH function actually be trapped and handled?  Any help would be appreciated.

 

1 ACCEPTED SOLUTION

Thank you for the information @v-shex-msft .  The problem needs to be solved in two steps.  Step one is to make a Parent Search Id using LOOKUPVALUE, as follows:

 

ParentSearchValue = 
  LOOKUPVALUE (
    [Id],
    [Id],
    [ParentId]
  )

The LOOKUPVALUE function handles the failures.  Step two is to proceed with determining the PATH, using ParentSearchValue instead of ParentId.

 

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @gaccardo-slb ,

I think path function analytic on whole field records instead each row. So if these records are not stored as parent child hierarchy, it will return error due to multiple available relationship mapping. 

In my opinion, you can add a calculated column to replace error records and use this column in path function.

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you for the information @v-shex-msft .  The problem needs to be solved in two steps.  Step one is to make a Parent Search Id using LOOKUPVALUE, as follows:

 

ParentSearchValue = 
  LOOKUPVALUE (
    [Id],
    [Id],
    [ParentId]
  )

The LOOKUPVALUE function handles the failures.  Step two is to proceed with determining the PATH, using ParentSearchValue instead of ParentId.

 

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Dev Camp Session 30

Ted's Dev Camp - January 26, 2023

This session will provide guidance and teach campers the skills required to build Power BI reports that support multiple languages.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.