Forum Discussion
dataflow - if there is a row present
hello,
in the dataflow gen2, there are several steps from navigation of the source all the way to pivot column.
After the pivot, the step is to rename column. But the flow fails on this rename step because if there is no data then the step fails as the column does not exists
Any suggestions ?
thank you
I would add a dummy row with the necessary columns before that step, so that the step doesn't fail, and then I would filter away the dummy row afterwards.
I created a HelperRow which only has columns and no rows.
Then after the pivot step, I appended this helper row.
It seems fine now
thank you
9 Replies
- lbendlinSuper User
use try ... otherwise ... to decide what to produce in this scenario.
- arkiboys2Helper IV
you mean to have try catch inside dataflow gen2? is this the only way?
how is this possible?
thanks
- frithjof_vCommunity Champion
You could add a dummy row.
However, do you want the dataflow to succeed if there is no data?
- frithjof_vCommunity Champion
If you want to do the try ... otherwise ... logic instead of adding a dummy row, there is a description in the link. I can actually recommend to go through all the parts of this series if you have the time:
https://bengribaudo.com/blog/2020/01/15/4883/power-query-m-primer-part-15-error-handling
I've done most of the parts, but I skipped the last ones as I didn't feel they were so relevant for my use cases at the time.
I don't think there are so many users who have gone through this series, but it gives a great theoretical description (and also many practical examples!) of the Power Query M language. If you have the time. I had already worked 3 years with Power BI/Power Query before I did this series.
- AnonymousNot applicable
Hi arkiboys2
If you use Table.RenameColumns to rename columns, a simple solution is to add MissingField.Ignore at the end. MissingField.Type - PowerQuery M | Microsoft Learn
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!