cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bloxvalz
New Member

Can I use a specific value in my parameter list to make a query?

Hi,

I need to create 6 distinct connections to pull data from AirTable databases. Each AirTable database is a little bit different.

Airtable's documentation for PowerQuery gives me a M formula which uses parameters for the API_KEY, the BASE_ID (i.e. the database), and TABLE_ID (tables/views in the database).

I have 6 TABLE_IDs. I created a single TABLE_ID parameter and added the 6 values as a list (see below). I want to control the M query by specifying WHICH of the 6 values in the TABLE_ID parameter list is used for the query.

i.e. instead of the paramter as TABLE_ID in the M query, provide TABLE_ID[1]. I can't find documentation for this.

Is this possible?:

bloxvalz_0-1631550026181.png



1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@bloxvalz 
I cannot see the TABLE_ID used in your codes. Basically you just replace the content with the parameter name. For example, I replace the 5 with "Period Days", the query result will change based on the parameter selection.

Vpazhenmsft_1-1631774648870.png

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

3 REPLIES 3
V-pazhen-msft
Community Support
Community Support

@bloxvalz 
I cannot see the TABLE_ID used in your codes. Basically you just replace the content with the parameter name. For example, I replace the 5 with "Period Days", the query result will change based on the parameter selection.

Vpazhenmsft_1-1631774648870.png

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

My TableID list is in the first post. The M query is in the second post. The M query has 2 places where the parameter is passed. 


I take it as I should build 6 separate queries and hardcode the values I want.

 

This will work but not what I was looking to do. I'll accept your solution. 

bloxvalz
New Member

FYI: here is the Airtable documentation including the query:
Sending Airtable data to Microsoft Power BI & Power Query – Airtable Support

let Pagination = List.Skip(List.Generate( () => [Last_Key = "init", Counter=0],

 each [Last_Key] <> null,

 each [

   Last_Key = try if [Counter]<1 then ""

   else

     [WebCall][Value][offset] otherwise null,

   WebCall = try if [Counter]<1

   then

   Json.Document(Web.Contents("https://api.airtable.com",

     [RelativePath="v0/"&BASE_ID&"/"&TABLE_ID&"?api_key="&API_KEY&""]))

   else

   Json.Document(Web.Contents("https://api.airtable.com",

     [RelativePath="v0/"&BASE_ID&"/"&TABLE_ID&"?api_key="&API_KEY&"&offset="&Last_Key&""])),

   Counter = [Counter]+1

 ],

 each [WebCall]

),1),

 #"Converted to Table" = Table.FromList(

   Pagination, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

 #"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"}),

 #"Renamed Columns" = Table.RenameColumns(

   #"Expanded Column1.Value.records1",{{"Column1.Value.records.id", "_airtableRecordId"},

   {"Column1.Value.records.createdTime", "_airtableRecordCreatedAt"},

   {"Column1.Value.records.fields", "_airtableRecordFields"}}),

 #"Reordered Columns" = Table.ReorderColumns(

   #"Renamed Columns",

   {"_airtableRecordId", "_airtableRecordCreatedAt", "_airtableRecordFields"}),

 #"Expanded Record Fields" = Table.ExpandRecordColumn(

   #"Reordered Columns", "_airtableRecordFields",

   Record.FieldNames(#"Reordered Columns"{0}[_airtableRecordFields]),

   Record.FieldNames(#"Reordered Columns"{0}[_airtableRecordFields]))

in

 #"Expanded Record Fields"

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors