Forum Discussion

jonoren's avatar
jonoren
Frequent Visitor
4 years ago
Solved

Get value from table by another rows value and the column name

So, my problem is as follows:

Firstly, I have the following table for currency exchange rates (for all currencies):

 

and second, I have a table of reservations, each reservation has a currency code and a date. I want to add the specific currency exchange rate for each reservation, but cant seem to understand how to do so.

 

Thank you!

 

4 Replies

  • KT_Bsmart2gethe's avatar
    KT_Bsmart2gethe
    Impactful Individual

    Hi jonoren ,

     

    If I understood correctly, you want to get the value from the reservations table to the currency rates table.

    There are a few ways to achieve it; however, without knowing what your reservations table's format is, I can only provide a brief direction:

     

    1. Unpivot the currency rates table to have all the code unpivoted, so you have a date and the code columns as key identifiers to apply the merge function.

     

    2. Add custom column and apply the Table.SelectRows(ReservationsTbl, (lookup)=> lookup[Date]=[Date Column from the reservation table] and lookup[Code]=[Code column from the reservation table])[return column name]{row number}

     

    Regards

    KT

    • jonoren's avatar
      jonoren
      Frequent Visitor

      I actually want the other way around, the reservations table has hundreds of columns so I prefer not to share a screenshot, but you can think of it as a table that looks like this:

       

      and I want it to be this (using the exchange rates table)

       

      Thanks a lot!

      • KT_Bsmart2gethe's avatar
        KT_Bsmart2gethe
        Impactful Individual

        Hi jonoren ,

         

        Step 1:

        Unpivot columns

         

         Step2:

        Merge

         

        Outcome:

         

        I hope it helps.

         

        Regards

        KT