Forum Discussion

harizothman's avatar
harizothman
Frequent Visitor
5 years ago
Solved

Lookup another data in different queries

Hi,

 

I hope everyone is doing great!

 

I really need help on this.

I have 2 sets of data from different files;

 

1. Training ID with finance status

Training IDFinance Status
A00001Invoices Pending
A00002Invoices Pending
A00003Invoices Complete
A00004Back Charged
A00005Back Charged

 

2. Training ID with learner details

Training IDFull NameUser ID
A00001Ainsley BrownAIBR
A00001Greg DavisGRDA
A00002Dennis PresleyDEPR
A00002Georgie CookGECO
A00003Eva RomeroEVRO
A00004Jessica GarlandJEGA
A00005Piers GreenwoodPIGR
A00005Joey BarberJOBA
A00005Sandra BarnettSABA

 

I would like to lookup the finance status from the 1st query into the 2nd query to be a new column as I want the trainings to match with the learner details. Something that looks like this;

 

Training IDFull NameFinance Status (new column)
A00001Ainsley BrownInvoices Pending
A00001Greg DavisInvoices Pending
A00002Dennis PresleyInvoices Pending
A00002Georgie CookInvoices Pending
A00003Eva RomeroInvoices Complete
A00004Jessica GarlandBack Charged
A00005Piers GreenwoodBack Charged
A00005Joey BarberBack Charged
A00005Sandra BarnettBack Charged

 

I want the data to be shown as a table and also as a filter to differentiate the learner details based on the finance status.

I tried the formula below but it took too long to load probably because my source of data is huge. 

Table.AddColumn(#"Renamed Columns", "Finance Status", each (let Session = [Training ID] in Table.SelectRows(#"First Query", each [Training ID] = Session)){0}[Finance Status])

 

Please help, thank you very much!

  • Hi harizothman 

     

    Add the the below lines right under you

    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Training ID"}, #"finance status", {"Training ID"}, "finance status", JoinKind.LeftOuter),
    #"Expanded finance status" = Table.ExpandTableColumn(#"Merged Queries", "finance status", {"Finance Status"}, {"Finance Status.1"})
    in
    #"Expanded finance status"

    Did it work ? Mark it as a solution to help spreading knowledge.

    A kudos would be appreciated

     

1 Reply

  • Hi harizothman 

     

    Add the the below lines right under you

    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Training ID"}, #"finance status", {"Training ID"}, "finance status", JoinKind.LeftOuter),
    #"Expanded finance status" = Table.ExpandTableColumn(#"Merged Queries", "finance status", {"Finance Status"}, {"Finance Status.1"})
    in
    #"Expanded finance status"

    Did it work ? Mark it as a solution to help spreading knowledge.

    A kudos would be appreciated