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
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
Hi Watkinnc, I'm trying to implement your solution but unfortunately it's a little different for me, I pull the data from a different system and will always get this result when there's "no data", usually if there is data it adds the column headers on the forth row and I proceed to formatting the whole table, but what would be your suggestion on this case?
hopefully my explination made sense.