Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Limiting query results based on a primary key from another query

I'll start this request by stating that I am new to Power BI and do not have experience using parameters and functions within Power Query yet, which is where I believe the answer to my question may be. 

 

I have Query 1 that has a column called "Id" which works as a unique identifier for the table.

I also have Query 2 named that has a column called "Requests Id" (matches to the codes from "Id" in Query 1), which will be used as the primary key between the tables for Query 2 and Query 1, as a many:1 relationship (Query2:Query1).

 

Because of the type of filtering I have in Query 1, I want to limit the load results of Query 2 to only the "Requests Id" lines that appear in the "Id" column of Query 1.  Below is an example:

 

Any idea of how I can limit the data, either using functions & parameters, or directly editing in advanced editor? I have looked at several other forums and YouTube tutorials, however, they've proven to either be too advanced for my current skillset, or based on simple date filtering or resulting in using the replicate & merge functions which is not applicable in my case. 

1 Reply

  • HotChilli's avatar
    HotChilli
    Icon for Community Champion rankCommunity Champion

    'Merge as new' using an Inner Join on id would be the best choice for novice users I think.  Why do you say "merge functions which is not applicable in my case"?

     

    For more advanced users, edit the Advanced Editor code by adding a line similar to

    Table.SelectRows(#"Changed Type", each  (List.Contains( #"Table 1"[id], [id])))

    where Table 1 is the first query.