Forum Discussion

amirabedhiafi's avatar
amirabedhiafi
Impactful Individual
5 years ago
Solved

Using a query in another query ?

f I want to use a query in another query what should I use :

  • reference
  • duplicate

or it is impossible and what's the difference between the 2 functions ?

  • amirabedhiafi when you duplicate, it will copy all the steps from the main query, which means you can make changes to these two queries independently.

     

    If you do a reference, it will use the main query as a source, and any change you make to the main query, it will be reflected to the reference query, although you can add a further step on the reference query.

     

    Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

2 Replies

  • amirabedhiafi when you duplicate, it will copy all the steps from the main query, which means you can make changes to these two queries independently.

     

    If you do a reference, it will use the main query as a source, and any change you make to the main query, it will be reflected to the reference query, although you can add a further step on the reference query.

     

    Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

  • Hi amirabedhiafi 

    Also, if you just want to use the result of a query in another query you can do so by using the first query's name.

    For example, if you have Query1 that produces a table with this code

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTJUitWJVkoCsozArGQgy1gpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Log = _t]),
        #"Removed Columns" = try Table.RemoveColumns(Source,{"Log"}) otherwise Source
    in
        #"Removed Columns"

     

    and you have another query, Query2, you can use the table produced by Query1 inside Query2 like this

    let
        Source = Query1
    in
        Source
        

    Regards

    Phil