• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Power Query - Check all Columns

Aquila

New Member
Every month, I need to perform a repetitive process, for which I need to verify that all the necessary columns are found in the table of origin. For example, in a table I only need the following columns: Employee, payment and discount, but sometimes the discount column does not come in the source table, so I need to create that column with a value in zero. In short, I need to create a column depending on whether it is not included in my original table. I hope you understand. Thanks a lot.
 
@Aquila... For excel file, you can also add this "Discount" column if doesn't exit using either IF then or try otherwise constructs like below.

=if Table.HasColumns(#"output table", "Discount") then #"output Headers" else Table.AddColumn(#"output Headers", "Discount", each 0),

= try Table.AddColumn(#"output table", "Discount", each 0) otherwise #"output table"

You can insert either of these as a step in your query. Not #"output table" is the previous step. So rename accordingly.
 
Back
Top