Forum Discussion

coollehavre's avatar
coollehavre
Frequent Visitor
8 years ago
Solved

lookup value in dax with bracket value

Hi, i have a table with number of days and i would like to display a sentence based on another table

It's easy to do this with VLOOKUP in Excel, but in DAX, how to do ?

 

  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi coollehavre,


    You can try to use below formula to create a calculate column to search the range label from other table.

    Range =
    VAR day_index =
        MAXX (
            FILTER ( ALL ( 'TableB'), 'TableB'[Days] < EARLIER ( 'TableA'[Days] ) ),
            [Days]
        )
    RETURN
        LOOKUPVALUE ( 'TableB'[Range], 'TableB'[Days], day_index )
    

     

    Regards,

    Xiaoxin Sheng

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Try this:

     

    =
    LOOKUPVALUE ( TableB[Libelle], TableB[Delai], VALUES ( TableA[Delai] ) )

    This will be a MEAUSURE, not a calculated column.  If you want a column, you can do this:

     

    =
    LOOKUPVALUE ( TableB[Libelle], TableB[Delai], TableA[Delai]  )

    You don't need the VALUES() function in the calculated column because you have a row context in Table A to get you the right value in the [Delai] column.  In the measure, you need VALUES() to get the proper scalar value from [Delai] column based on the current filter context.

     

    Hope this helps!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi coollehavre,


    You can try to use below formula to create a calculate column to search the range label from other table.

    Range =
    VAR day_index =
        MAXX (
            FILTER ( ALL ( 'TableB'), 'TableB'[Days] < EARLIER ( 'TableA'[Days] ) ),
            [Days]
        )
    RETURN
        LOOKUPVALUE ( 'TableB'[Range], 'TableB'[Days], day_index )
    

     

    Regards,

    Xiaoxin Sheng