Forum Discussion
Error handling when table is empty
- Anonymous3 years ago
Try this:
= Table.AddColumn(PriorStepOrTableName, "TableToExpand", each if Table.IsEmpty(_[Data]) then Table.FromColumns({{null}, {null}, {null}, {null}}, {"Column1", "Column2", "Column3", "Column4"}) else [Data])
Now if the table is empty, you'll get a 4 column, 1 row table of null values. Make as many nulls and column names as you need. You should replace my "Column1" names with the actual column names.
--Nate
I was looking to get the real table data rather than just the result of the first step. I didn't explain myself properly. Perhaps you can use the try ... otherwise .... construct to catch the errors and return an alternative result in case they occur
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers