powerbipowerqueryairtable

Pulling Data from Airtable to PowerBI - Certain Columns Pulled in as Lists, Cannot Get the Data


I need your help please to address an issue when importing data from an Airtable view where columns with multiple values in them (multi-select) only show up as "List" once imported to Power BI. Data in Airtable populated by drop down options does not come through into Power BI as usable data. For example, in Airtable when you must select an option for data entry, such as "Country - options being Indonesia, Philippines, Qatar, etc.", it displays in "List" when imported into PBI. This may be better explained using screenshots.

This is the column in Airtable which is being pulled through incorrectly

[This is what I can see pulled into PBI, it just says '[List]' instead of listing all of the countries separately] (https://i.sstatic.net/9cK3j.png)

I was wondering if there was a simple workaround to this issue? All other columns have been pulled in perfectly and work as they should.

I have used PowerQuery to pull the data from my Airtable view into PBI using this code: https://github.com/Airtable-Labs/msft-power-query-m-language/blob/main/retrieve-all-records-from-view.m and these steps: https://support.airtable.com/docs/visualizing-airtable-records-in-microsoft-power-bi-power-query.

CODE:

let 
    // Pagination Logic: This part handles pagination by making API calls to Airtable with different offsets to retrieve paginated data.
    Pagination = List.Skip(
        List.Generate(
            () => [Page_Key = "init", Counter=0], // Initialize page key and counter
            each [Page_Key] <> null, // Continue generating while Page_Key is not null
            each [
                Page_Key = try if [Counter] < 1 then "" else [WebCall][Value][offset] otherwise null, // Determine the next Page_Key
                WebCall = try if [Counter] < 1 then
                    // Initial API call without offset
                    Json.Document(
                        Web.Contents(
                            "https://api.airtable.com",
                            [
                                RelativePath = "v0/" & BASE_ID & "/" & TABLE_ID & "?view=" & VIEW_ID,
                                Headers = [Authorization = "Bearer " & PERSONAL_ACCESS_TOKEN]
                            ]
                        )
                    )
                else
                    // Subsequent API calls with offset
                    Json.Document(
                        Web.Contents(
                            "https://api.airtable.com",
                            [
                                RelativePath = "v0/" & BASE_ID & "/" & TABLE_ID & "?view=" & VIEW_ID & "&offset=" & [WebCall][Value][offset],
                                Headers = [Authorization = "Bearer " & PERSONAL_ACCESS_TOKEN]
                            ]
                        )
                    ),
                Counter = [Counter] + 1 // Increment the counter for each iteration
            ],
            each [WebCall]
        ),
        1
    ),

    // Convert the paginated data into a table
    #"Converted to Table" = Table.FromList(
        Pagination, Splitter.SplitByNothing(), null, null, ExtraValues.Error
    ),

    // Expand and structure the paginated data
    #"Expanded Column1" = Table.ExpandRecordColumn(
        #"Converted to Table", "Column1", {"Value"}, {"Column1.Value"}
    ),
    #"Expanded Column1.Value" = Table.ExpandRecordColumn(
        #"Expanded Column1", "Column1.Value", {"records"}, {"Column1.Value.records"}
    ),
    #"Expanded Column1.Value.records" = Table.ExpandListColumn(
        #"Expanded Column1.Value", "Column1.Value.records"
    ),
    #"Expanded Column1.Value.records1" = Table.ExpandRecordColumn(
        #"Expanded Column1.Value.records", "Column1.Value.records",
        {"id", "fields", "createdTime"},
        {"Column1.Value.records.id", "Column1.Value.records.fields", "Column1.Value.records.createdTime"}
    ),

    // Rename columns to align with a specific naming convention.
    #"Renamed Columns" = Table.RenameColumns(
        #"Expanded Column1.Value.records1",
        {
            {"Column1.Value.records.id", "_airtableRecordId"},
            {"Column1.Value.records.createdTime", "_airtableRecordCreatedAt"},
            {"Column1.Value.records.fields", "_airtableRecordFields"}
        }
    ),

    // Reorder columns to the desired order.
    #"Reordered Columns" = Table.ReorderColumns(
        #"Renamed Columns",
        {"_airtableRecordId", "_airtableRecordCreatedAt", "_airtableRecordFields"}
    ),

    // Expand the record fields dynamically based on distinct field names, ensuring that all fields are expanded regardless of schema changes.
    #"Expanded Record Fields" = Table.ExpandRecordColumn(
        #"Reordered Columns", "_airtableRecordFields",
        List.Distinct(List.Combine(List.Transform(
            List.Transform(Table.ToRecords(#"Reordered Columns"), each Record.Field(_, "_airtableRecordFields")),
            each Record.FieldNames(_)
        ))),
        List.Distinct(List.Combine(List.Transform(
            List.Transform(Table.ToRecords(#"Reordered Columns"), each Record.Field(_, "_airtableRecordFields")),
            each Record.FieldNames(_)
        )))
    )
in
    #"Expanded Record Fields"

Please be as specific as possible in your response as I am NOT an expert with any of this and rely a lot on the web, as well as this community, for complicated formulas. Sorry if my terminology is off. I appreciate your guidance and ideas.

I have tried everything, from making a new column in Airtable to try and pull the data in another way, and also have scoured the internet but have not managed to find a suitable workaround. Any and all help would be massively appreciated.

---- UPDATE ----:

Using the first solution in the comment below produced the following error....

Query Error


Solution

  • What do you want to do with it?

    You can convert all the blanks/nulls to blank lists, then expand the data into rows, one per row per each item in each list, with all other columns being duplicated

    #"Transform"=Table.TransformColumns(#"UsePriorStepNameHere", {{“Counties Involved”, each try if Value.Is(_, type list) then _ else {_} otherwise {}}} ),
    #"Expanded Counties Involved" = Table.ExpandListColumn( #"Transform", "Counties Involved")
    

    or you can add a custom column to combine together the items of each list separated by some character, here a comma

    #"Added Custom" = Table.AddColumn(#"UsePriorStepNameHere", "CountriesInvolved2", each try Text.Combine([Counties Involved],",") otherwise null)
    

    enter image description here