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
Anonymous
Not applicable

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?

1 ACCEPTED SOLUTION
MFelix
Super User
Super 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
    Custom1

See 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


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super 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
    Custom1

See 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


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Greg_Deckler
Super User
Super User

I would call @ImkeF in for a rescue here but Notifications are not working. I would send her a private message.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.