Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Some Help with a conditional DAX lookup please

I have 2 tables, both of which contain a column named 'Site Number'.

 

I would like to create a column in one of the tables which looks up the 'Site Attribute Value' from the below table where the 'Site Attribute Name' is 'Region(5)', by 'Site Number'.  The 'Site Attribute Name' column contains a myriad of different content.

 

In my head I am thinking of this as a 'conditional lookup' but not sure how to write the DAX to do this?

 

If anyone could offer a suggestion as to how to do this I would be eternally grateful :smileyhappy:

 

  • Hi Anonymous 

    Based on my understanding, i make a test as below.

    1. Test data:

    Sheet1

    Site attribute name site attribure value site number
    region(1) LK 1
    region(3) DF 4
    region(5) L&HC 23
    region(5) L&HC 24
    region(5) L&HC 25
    region(1) r 23
    region(1) f 24
    region(1) g 25

    Sheet2

    site number
    1
    4
    23
    24
    25

     

    2. Create relationships between two tables

     

    3. Create a calculated columns in Sheet2

    Column = 
    LOOKUPVALUE(Sheet1[site attribure value],Sheet1[site number],Sheet2[site number],Sheet1[Site attribute name],"region(5)")

     

    Best Regards

    Maggie

     

    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • v-juanli-msft's avatar
    v-juanli-msft
    Community Support

    Hi Anonymous 

    Based on my understanding, i make a test as below.

    1. Test data:

    Sheet1

    Site attribute name site attribure value site number
    region(1) LK 1
    region(3) DF 4
    region(5) L&HC 23
    region(5) L&HC 24
    region(5) L&HC 25
    region(1) r 23
    region(1) f 24
    region(1) g 25

    Sheet2

    site number
    1
    4
    23
    24
    25

     

    2. Create relationships between two tables

     

    3. Create a calculated columns in Sheet2

    Column = 
    LOOKUPVALUE(Sheet1[site attribure value],Sheet1[site number],Sheet2[site number],Sheet1[Site attribute name],"region(5)")

     

    Best Regards

    Maggie

     

    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much Maggie; that's done the trick.  I wasn't aware you could add a condition to the end of the Lookup syntax so much appreciated