Forum Discussion

mdobrescu's avatar
mdobrescu
New Member
4 years ago
Solved

Parse data before import to dataset

Hello,   I have a CSV file hosted on OneDrive Bussines which is linked to a PowerBi dataset.  Lets say both the CSV file and Powerbi dataset have 3 columns(column1, column2, column3). But sometim...
  • Anonymous's avatar
    Anonymous
    4 years ago

    HI mdobrescu,

    According to your description, I'd like to suggest you can add a custom query step with an if statement to check the data source fields. Then use the current result or try to use add column function to add these missed columns.

    Table.ColumnCount - PowerQuery M | Microsoft Docs

    Table.AddColumn - PowerQuery M | Microsoft Docs

        Source = xxxxxx,
        Custom=
            if Table.ColumnCount(Source) > 2 then
                Source
            else
                Table.AddColumn(
                    Source,
                    "column2",
                    each null
                )
    in
        Custom

    Regards,

    Xiaoxin Sheng