Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

New Colum based on ID

I'm looking to create a new column in my data model that displays different values based on the user[ID]:

  1. If user[ID] >= 50, I want to retrieve the name from the entity table using the formula: LOOKUPVALUE(entity[Name], entity[Entity ID], user[Entity ID])

  2. If user[ID] < 50, I want to retrieve the name from the old_entity table using the formula: LOOKUPVALUE(old_entity[Name], old_entity[Entity ID], user[Entity ID])

I'm not sure how to accomplish this in DAX. Can anyone help with the correct DAX formula for this scenario?

Thank you!

  • Anonymous Seems like:

    Column in User Table =
      VAR __ID = [ID]
      VAR __Result = 
        SWITCH( TRUE(),
          [ID] >= 50, LOOKUPVALUE( entity[Name], entity[Entity ID], __ID ),
          LOOKUPVALUE( old_entity[Name], old_entity[Entity ID], __ID )
        )
    RETURN
      __Result

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous Seems like:

    Column in User Table =
      VAR __ID = [ID]
      VAR __Result = 
        SWITCH( TRUE(),
          [ID] >= 50, LOOKUPVALUE( entity[Name], entity[Entity ID], __ID ),
          LOOKUPVALUE( old_entity[Name], old_entity[Entity ID], __ID )
        )
    RETURN
      __Result
  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you so much for the help! Your suggestions worked perfectly!