Forum Discussion
Referencing a table within a seperate query in Power Query
I have 2 querys in Power Query, lets call them Query1 and Query2.
I need to use an index from a table in Query2 to remove a dynamic number of top rows in Query1.
I know how to reference a table within the same query, but I'm not sure the syntax to reference the seperate query.
The funtion would be = Table.Skip(#"Query1, ??????)
How can I phrase that second parameter to look to the index column on the table within Query2?
HI Anonymous,
You can reference in several ways depends also on the information you need. In the example below I created 2 tables and make reference of the first in the second table. (very simply and iniffective example from the data point of view).
Table1 let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlaKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]) in Source Table2 let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzMGkOJi3ApCWYNDRQio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}), Custom1 = Table.Skip(#"Changed Type",Number.FromText(List.Max(Table.ToList(Table1)))) in Custom1See code above for 2 simple tables where In step Custom1 I reference to the Table1 data to get information for the calculation.
If you also add a blank step on your query you can reference the other query by name simply:
= QueryThatYouWantToReference
Then you have the query within the steps and can reference back to it, as you refer.
Hope this helps.
Regards,
MFelix
2 Replies
- MFelixSuper User
HI Anonymous,
You can reference in several ways depends also on the information you need. In the example below I created 2 tables and make reference of the first in the second table. (very simply and iniffective example from the data point of view).
Table1 let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlaKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]) in Source Table2 let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzMGkOJi3ApCWYNDRQio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}), Custom1 = Table.Skip(#"Changed Type",Number.FromText(List.Max(Table.ToList(Table1)))) in Custom1See code above for 2 simple tables where In step Custom1 I reference to the Table1 data to get information for the calculation.
If you also add a blank step on your query you can reference the other query by name simply:
= QueryThatYouWantToReference
Then you have the query within the steps and can reference back to it, as you refer.
Hope this helps.
Regards,
MFelix
- Greg_DecklerCommunity Champion
I would call ImkeF in for a rescue here but Notifications are not working. I would send her a private message.