Forum Discussion

Frostjr's avatar
Frostjr
Regular Visitor
3 years ago
Solved

Range Lookup in different tables

Hello.

 

I need help in terms of looking up a number on a specific date and time within a time range with a specific date and time. 

 

I have two tables in my Power Query.

 

The first table is called "JOBR_RESOURCE" and looks like this: 

 

The second table is called "Hovedrapport" and looks like this:

 

So what i want is connecting the "Materiale nummer" to the specific time and date in the first table if "JOBR_TS" is between/within the "ACTUAL_START_TS" and "ACTUAL_END_TS". 

 

It also needs to take into consideration that it must be for the given machine. The machine is in the first table "FK_RESOURCEID" and in the second table it is "FK_RESOURCEID_PLANNED". 

 

So it both needs to take into consideration that it is on the given machine and if the date is within the time range it is given "Materiale nummer" that is running on the machine. 

 

Extra information that it needs to be a formula that can work with a big dataset. 

 

So the end game would be a table that looks like this: 

 

Hope that someone can help with this problem. I would appreciate it!

Ask if you need anymore information or something is not clear 🙂

 

 

 

 

 

  • Frostjr , New column in JOBR_RESOURCE using  DAX

     

    =

    maxx(filter(Hovedrapport,JOBR_RESOURCE [JOBR_TS]>= Hovedrapport[Actutal_start_TS]   && JOBR_RESOURCE [JOBR_TS]<= Hovedrapport[Actutal_start_TS]  && ,JOBR_RESOURCE [FK_RESOURCE_ID]= Hovedrapport[FK_RESOURCE_PLANNED_ID]  ), Hovedrapport[Material_number])

     

    change or add conditions as per need

     

    refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
    https://www.youtube.com/watch?v=Wu1mWxR23jU
    https://www.youtube.com/watch?v=czNHt7UXIe8

1 Reply

  • Frostjr , New column in JOBR_RESOURCE using  DAX

     

    =

    maxx(filter(Hovedrapport,JOBR_RESOURCE [JOBR_TS]>= Hovedrapport[Actutal_start_TS]   && JOBR_RESOURCE [JOBR_TS]<= Hovedrapport[Actutal_start_TS]  && ,JOBR_RESOURCE [FK_RESOURCE_ID]= Hovedrapport[FK_RESOURCE_PLANNED_ID]  ), Hovedrapport[Material_number])

     

    change or add conditions as per need

     

    refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
    https://www.youtube.com/watch?v=Wu1mWxR23jU
    https://www.youtube.com/watch?v=czNHt7UXIe8