Forum Discussion

rahul632soni's avatar
rahul632soni
Icon for Helper I rankHelper I
3 years ago
Solved

how to lookup data from one table to another table using range for dynamic range of values

Hey

 

I have two table . 

First Table

Header NameBase UnitStart Engine HoursStop Engine Hours
AHAJW210HKMG6799241030
AHAJSR26VTNG680048980.91005.8
AHAJSR26HKMG679915947.8974.3
BHAJSR26HLMG679906739.4756.1
BHAJW210HKMG6799241234.51283.7
BHAJSR26VTNG6800481006.91051.7
CHAJSR26HKMG679915789.5875.8
CHAJW210VVNG6805211.55.1
CHAJW210HKMG6799241284.11333.5
DHAJSR22HKMG679922254270
DHAJSR22HPMG679921290310
EHAJSR22HPMG679921290310
EHAJSR22HPMG679921290310
AHAJW210HKMG679924200

230

 

 

Second Table

vin17ENG_HOURSgps_timestampAverage of AMBIENT_AIR_TEMPERATURE
HAJW210HKMG679924107/29/2021 15:5945
HAJW210HKMG679924207/29/2021 16:0045
HAJW210HKMG679924307/29/2021 16:0245
HAJW210HKMG679924407/29/2021 16:0344
HAJSR26VTNG680048507/29/2021 16:0442
HAJSR26VTNG680048607/29/2021 16:0542
HAJSR26VTNG680048707/29/2021 16:0643
HAJW210HKMG679924807/29/2021 16:0744
HAJW210HKMG679924907/29/2021 16:0844
HAJW210HKMG6799241007/29/2021 16:0945
HAJW210HKMG6799241107/29/2021 16:1045
HAJW210HKMG6799241207/29/2021 16:1146
HAJW210HKMG6799241307/29/2021 16:1246
HAJW210HKMG6799241407/29/2021 16:1346
HAJW210HKMG6799241507/29/2021 16:1446
HAJW210HKMG6799241607/29/2021 16:1546
HAJW210HKMG6799241707/29/2021 16:1646
HAJW210HKMG6799241807/29/2021 16:1847
HAJW210HKMG6799241907/29/2021 16:1947
HAJW210HKMG6799242007/29/2021 16:2047
HAJW210HKMG6799242107/29/2021 16:2348
HAJW210HKMG6799242207/29/2021 16:2649
HAJW210HKMG6799242308/5/2021 14:4427
HAJSR26HLMG679906229.88/6/2021 16:5649
HAJSR26HLMG679906229.88/6/2021 16:5749
HAJSR26HLMG679906229.88/6/2021 16:5850
HAJSR26HLMG679906229.88/6/2021 16:5951
HAJSR26HLMG679906229.98/6/2021 17:0051
HAJSR26HLMG679906229.98/6/2021 17:0151
HAJSR26HLMG679906229.98/6/2021 17:0249
HAJSR26HLMG679906229.98/6/2021 17:0348
HAJSR26HLMG679906229.98/6/2021 17:0448
HAJSR26HLMG679906229.98/6/2021 17:0548
HAJSR26HLMG6799062308/6/2021 17:0649
HAJSR26HLMG6799062308/6/2021 17:0748
HAJSR26HLMG6799062308/6/2021 17:0848
HAJSR26HLMG6799062308/6/2021 17:0946
HAJSR26HLMG6799062308/6/2021 17:1045
HAJSR26HLMG6799062308/6/2021 17:1147
HAJSR26HLMG679906230.18/6/2021 17:1249
HAJSR26HLMG679906230.18/6/2021 17:1351
HAJSR26HLMG679906230.18/6/2021 17:1452
HAJSR26HLMG679906230.18/6/2021 17:1554
HAJSR26HLMG679906230.18/6/2021 17:1756
HAJSR26HLMG679906230.28/6/2021 17:1957
HAJSR26HLMG679906230.28/6/2021 17:2157
HAJSR26HLMG679906230.28/6/2021 17:2257
HAJSR26HLMG679906230.28/6/2021 17:2358
HAJSR26HLMG679906230.28/6/2021 17:2458
HAJSR26HLMG679906230.38/6/2021 17:2658
HAJSR26HLMG679906230.38/6/2021 17:3058
HAJSR26HLMG679906230.48/6/2021 17:3158
HAJSR26HLMG679906230.48/6/2021 17:3358
HAJSR26HLMG679906230.48/6/2021 17:3457
HAJSR26HLMG679906230.48/6/2021 17:3558
HAJSR26HLMG679906230.58/6/2021 17:3758
HAJSR26HLMG679906230.58/6/2021 17:3858
HAJSR26HLMG679906230.58/6/2021 17:3957
HAJSR26HLMG679906230.58/6/2021 17:4057
HAJSR26HLMG679906230.58/6/2021 17:4157
HAJSR26HLMG679906230.58/6/2021 17:4257
HAJSR26HLMG679906230.68/6/2021 17:4358
HAJSR26HLMG679906230.68/6/2021 17:4457

How Can I lookup Header Name from Table one into Table two where Engine hours Fall between Start Engine Hours  and Stop Engine Hours for each Base Unit ?

 

5 Replies

  • bhelou's avatar
    bhelou
    Icon for Responsive Resident rankResponsive Resident

    Hi , please can tyou share a sample ,this  looks intresting to solve

    • rahul632soni's avatar
      rahul632soni
      Icon for Helper I rankHelper I

      Hey bhelou 

       

      Actually I have two Different Table as you can see above .

      Actulay I wanted to create a Visual through which,  if i select Any Header from Table 1,  i should get only those data From Table 2 where the Engine Hours is same as Start and Stop for Header A in Table 1 .

       

      For that we are able to lookup the Header name from Table 1 to Table 2 with condition that the Engine Hours is in Between start and stop of Table 1 .

      Solution shared by by amitchandak  is working almost except for those cases where we have more than 1 start and stop Engine Hours for Header with Same Base Unit .

       

      Let me Know if you required any other Information.

       

      Regards

      Rahul Soni

  • rahul632soni , new column in tabl2 , based on what I got

     

    Maxx(filter(Table1, Table1[Base Unit] = Table2[vin17] && Table1[Start Engine Hours] <= Table2[ENG_HOURS]  && Table1[End Engine Hours] >= Table2[ENG_HOURS] ) ,Table1[Header Name] )

     

     

    you can use any other column based in 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

     

    Winin table

     

    DAX- Earlier, I should have known Earlier: https://www.youtube.com/watch?v=cN8AO3_vmlY&t=17820s

    • rahul632soni's avatar
      rahul632soni
      Icon for Helper I rankHelper I

      amitchandak  Hey Thanks For Solution Its Working almost However IN Case where we have Same Header Attachewd to Same Base Unit Twice with Two Different Engine Hours Range , its not Doing Lookup for Example in Below Table we can see

      HeaderBase UnitStartStop
      AHAJW210HKMG6799241030
      AHAJW210HKMG679924200230

      Header A in Table 1 Attached to a Base Unit Twice  with Two Different Tenure of Engine Hours , and Now After First Filter of VIn in Second Filter out of These Two Start and Stop Hours its not taking any , means i ma not getting any lookup value for this VIn.

      Can you Help with this as well ?

      Thanks in Advance

      Regards

      Rahul

    • rahul632soni's avatar
      rahul632soni
      Icon for Helper I rankHelper I

      Hey amitchandak  Thanks For Solution , its Working almost however in some cases where we have Header is attached to Same base unit more than once for Example , In Below Table

      HeaderBase UnitStartStop
      AHAJW210HKMG6799241030
      AHAJW210HKMG679924200230

       

      Header A is Attached to a Vin two times with two Different range of Engine Hours. In this scenario Lookup is not working 

       

      Can you Help with this also?

       

      Regards

      Rahul Soni