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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
primolee
Helper V
Helper V

List all errors in a table

Hello there,

 

Is there a way to keep rows with errors and also keep the cause of these errors in a column?

 

Because I have 60 columns, if there are 2 or more errors in a row, is there a way to keep these error messages in a column or list?

 

Thank you so much for your time and help.

 

Best Regards,

David

1 ACCEPTED SOLUTION
Smauro
Solution Sage
Solution Sage

Hi @primolee 

I use this function sometimes:

(table as table) as table =>
    let
        errorExtract = (value as any) as any => if value[HasError] = true then value[Error] else value[Value],

        errorToText = (errorRec as any) as any => if Type.Is(Value.Type(errorRec), Record.Type) then "Reason: " & errorRec[Reason] & "#(lf)Message: " & errorRec[Message] & "#(lf)Value: " & (try Text.From(errorRec[Detail]) otherwise try Text.From(errorRec[Detail][Value]) otherwise null) else errorRec,

        recsToErrors = (rec as record) as any =>
            List.Accumulate( Record.FieldNames(rec), [],
                (s,c) => Record.AddField(s, c, errorToText(errorExtract(try Record.Field(rec, c)) ) ) ),

        
        #"Error Table" = Table.FromList(List.Transform(Table.ToRecords(Table.SelectRowsWithErrors(table)), each recsToErrors(_)), Record.FieldValues, Table.ColumnNames(table))
    in
        #"Error Table"

It keeps only error rows and transforms errors to the text of the error record. It may be useful to you.

 

 

Best,

Spyros




Spyros Mavroforos

Data Consultant


Find me on LinkedIn or drop me an email

eSpyros

View solution in original post

5 REPLIES 5
Smauro
Solution Sage
Solution Sage

Hi @primolee 

I use this function sometimes:

(table as table) as table =>
    let
        errorExtract = (value as any) as any => if value[HasError] = true then value[Error] else value[Value],

        errorToText = (errorRec as any) as any => if Type.Is(Value.Type(errorRec), Record.Type) then "Reason: " & errorRec[Reason] & "#(lf)Message: " & errorRec[Message] & "#(lf)Value: " & (try Text.From(errorRec[Detail]) otherwise try Text.From(errorRec[Detail][Value]) otherwise null) else errorRec,

        recsToErrors = (rec as record) as any =>
            List.Accumulate( Record.FieldNames(rec), [],
                (s,c) => Record.AddField(s, c, errorToText(errorExtract(try Record.Field(rec, c)) ) ) ),

        
        #"Error Table" = Table.FromList(List.Transform(Table.ToRecords(Table.SelectRowsWithErrors(table)), each recsToErrors(_)), Record.FieldValues, Table.ColumnNames(table))
    in
        #"Error Table"

It keeps only error rows and transforms errors to the text of the error record. It may be useful to you.

 

 

Best,

Spyros




Spyros Mavroforos

Data Consultant


Find me on LinkedIn or drop me an email

eSpyros

Anonymous
Not applicable

Amazing, thx!!

THIS IS BRILLIANT!!!!!

@Smauro  Hello!

 

Thank you so much for your help!  This function is so convenient!!!  Just gave it a try, so simple!

 

Thank you!!!!

PhilipTreacy
Super User
Super User

Hi @primolee 

Yes, please refer to this article

 https://www.sumproduct.com/blog/article/power-query-blogs/power-query-trying-to-extract-errors

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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