I’m facing a challenge when transferring data from Airtable into Power BI. Specifically, columns that contain multiple selections are only showing up as [List] instead of the individual selections.
For instance, there’s a dropdown in Airtable for selecting various countries such as Vietnam, India, and Japan. However, upon importing this data into Power BI, it shows [List] rather than the actual country names that were selected.
I’ve been utilizing Power Query along with some custom M code to connect to my Airtable view. Below is the snippet of the code I have been working with:
let
// Handle pagination to fetch data from Airtable in batches
PagesOfData = List.Skip(
List.Generate(
() => [NextPageToken = "firstPage", Counter=0],
each [NextPageToken] <> null,
each [
NextPageToken = try if [Counter] < 1 then "" else [Response][Value][offset] otherwise null,
Response = try if [Counter] < 1 then
Json.Document(
Web.Contents(
"https://api.airtable.com",
[
RelativePath = "v0/" & DB_ID & "/" & SHEET_NAME & "?view=" & VIEW_SET,
Headers = [Authorization = "Bearer " & TOKEN]
]
)
)
else
Json.Document(
Web.Contents(
"https://api.airtable.com",
[
RelativePath = "v0/" & DB_ID & "/" & SHEET_NAME & "?view=" & VIEW_SET & "&offset=" & [Response][Value][offset],
Headers = [Authorization = "Bearer " & TOKEN]
]
)
),
Counter = [Counter] + 1
],
each [Response]
),
1
),
// Format the paginated response into a table structure
#"Created Table" = Table.FromList(
PagesOfData, Splitter.SplitByNothing(), null, null, ExtraValues.Error
),
// Extract and expand the nested data fields
#"Unpacked Column1" = Table.ExpandRecordColumn(
#"Created Table", "Column1", {"Value"}, {"Column1.Value"}
),
#"Unpacked Column1.Value" = Table.ExpandRecordColumn(
#"Unpacked Column1", "Column1.Value", {"records"}, {"Column1.Value.records"}
),
#"Unpacked Column1.Value.records" = Table.ExpandListColumn(
#"Unpacked Column1.Value", "Column1.Value.records"
),
#"Unpacked Column1.Value.recordsDetails" = Table.ExpandRecordColumn(
#"Unpacked Column1.Value.records", "Column1.Value.records",
{"id", "fields", "createdTime"},
{"Column1.Value.records.id", "Column1.Value.records.fields", "Column1.Value.records.createdTime"}
),
// Rename columns for better clarity
#"Renamed Columns" = Table.RenameColumns(
#"Unpacked Column1.Value.recordsDetails",
{
{"Column1.Value.records.id", "_recordID"},
{"Column1.Value.records.createdTime", "_recordTimestamp"},
{"Column1.Value.records.fields", "_recordFields"}
}
),
// Rearrange columns to match expected layout
#"Rearranged Columns" = Table.ReorderColumns(
#"Renamed Columns",
{"_recordID", "_recordTimestamp", "_recordFields"}
),
// Expand field data dynamically to adapt to potential schema modifications
#"Expanded Field Data" = Table.ExpandRecordColumn(
#"Rearranged Columns", "_recordFields",
List.Distinct(List.Combine(List.Transform(
List.Transform(Table.ToRecords(#"Rearranged Columns"), each Record.Field(_, "_recordFields")),
each Record.FieldNames(_)
))),
List.Distinct(List.Combine(List.Transform(
List.Transform(Table.ToRecords(#"Rearranged Columns"), each Record.Field(_, "_recordFields")),
each Record.FieldNames(_)
)))
)
in
#"Expanded Field Data"
I lack extensive experience with Power Query and M language, so I would appreciate any guidance on how to effectively unpack these list values. I’ve attempted creating new columns in Airtable and researched solutions, but nothing has worked so far. Any help on how to adjust this code for correctly displaying the multi-select values would be greatly valued!