Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

 

 

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors