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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
mjohnsonuk
Frequent Visitor

Using Keylists with existing queries???

Hi All

 

I have a query about Keylists, I have used them fine in the past although they can be slow to reload - I was wondering if there is another way ??

the first part of the query highlights the jobs I wish to look up in other tables (these can contain up to 10m lines of data)

I would like to do this for multiple tables and I was wondering if this is the wrong way to pull the detail in - would it be better to create a query pulling in the keylist then reference this on each table ?? although I am not sure how to reference this .......

I hope this makes sense

Thanks

 

My query is as follows:

let
    Source = Odbc.Query("***=**********",
    "Select
    #(lf)CONCAT(a.job_no,'-',a.job_rfa_no) AS job_rfa
    #(lf)FROM job_open.job_visit a
    #(lf)WHERE a.acty_cmpnent_vst_date >= ""2018-01-01"""),

    #"Added Custom" = Table.AddColumn(Source, "job_rfa_keylist", each "'"&[job_rfa]&"'"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"job_rfa"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Columns"),

    keylist= Text.Combine(#"Removed Duplicates"[job_rfa_keylist],","),

    Source1 = Odbc.Query("***=**********",
    "Select
    #(lf)CONCAT(a.job_no,'-',a.job_rfa_no) AS job_rfa,
    #(lf)a.contract_ind,
    #(lf)a.skill_code
    #(lf)FROM job_open.job_table2 a
    #(lf)WHERE CONCAT(a.job_no,'-',a.job_rfa_no) IN (" & keylist & ");")
in
    Source1

1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @mjohnsonuk,

 

I would suggest you create a single SQL query. Actually, you don't need to format the [keylist] in the Power Query. Please try out this one.

 

SELECT Concat(a.job_no, '-', a.job_rfa_no) AS job_rfa, 
       a.contract_ind, 
       a.skill_code 
FROM   job_open.job_table2 a 
WHERE  Concat(a.job_no, '-', a.job_rfa_no) IN (SELECT 
       Concat(b.job_no, '-', b.job_rfa_no) 
                                               FROM   job_open.job_visit b 
                                               WHERE 
              b.acty_cmpnent_vst_date >= '2018-01-01');

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @mjohnsonuk,

 

I would suggest you create a single SQL query. Actually, you don't need to format the [keylist] in the Power Query. Please try out this one.

 

SELECT Concat(a.job_no, '-', a.job_rfa_no) AS job_rfa, 
       a.contract_ind, 
       a.skill_code 
FROM   job_open.job_table2 a 
WHERE  Concat(a.job_no, '-', a.job_rfa_no) IN (SELECT 
       Concat(b.job_no, '-', b.job_rfa_no) 
                                               FROM   job_open.job_visit b 
                                               WHERE 
              b.acty_cmpnent_vst_date >= '2018-01-01');

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.