Forum Discussion

michellepace's avatar
michellepace
Icon for Resolver III rankResolver III
7 years ago
Solved

Create a column based on a lookup in another table

Hi, I've spent the last hour trying to understand this and google around. I must be missing something completely because it simply cannot be that difficult. Alright, I have the below two tables:

 

___________________

Table 1: 

AccNumber |

 

Table 2:

AccNumber | AccDescrip

___________________

 

All I want to do is create an additional calculated column called "Main" in Table 1. Where for each row, the equivalent vlookup function would be: 

 

Main = vlookup( Table1.AccNumber * 1000,  Table2,  2,  False)

 

Could anyone please shed some light as to what my formula would be for creating a calculated column?

 

  • dax's avatar
    dax
    7 years ago

    Hi michellepace,

    You could try below

    Column = LOOKUPVALUE('Table2'[AccNumber],'Table2'[AccNumber],'Table 1'[AccNumber])*1000

    Best Regards,
    Zoe Zhi

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Hi, it's amazing how I can make something so simple so complicated :). The RELATED function worked for me. Just posting this pic here for anyone else who may find it useful. 

     

8 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

    Given that there is relationship between 2 tables, you can use RELATED function in DAX to achieve this:

    Use the below code to create the column in Table 2.

    Main = RELATED( Table1[AccNumber] )

    Thanks.

    • michellepace's avatar
      michellepace
      Icon for Resolver III rankResolver III

      Hi Anonymous , thank you for your reply. I've tried to follow your advice but obviously I'm getting something wrong... can anyone please tell me why I am getting this error? As far as I can see my syntax is correct...?

       

      • dax's avatar
        dax
        Icon for Community Support rankCommunity Support

        Hi michellepace,

        You could try below

        Column = LOOKUPVALUE('Table2'[AccNumber],'Table2'[AccNumber],'Table 1'[AccNumber])*1000

        Best Regards,
        Zoe Zhi

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.