Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

RELATEDTABLE + CALCULATE proper usage

I have two tables: Customer and Last login. (1 to many relationship)
Last login contains email addresses and their last login timestamp.
What I want is to create a calculated column in Customer table containing the most recent email address logged in for that customer.
I tried this but DAX does not like me and complains.
email = CALCULATE(RELATEDTABLE('Last login'[Email]));'Last login'[Timestamp] = Customer[Last login])
I've already spent 3hours googleing the solution but with no success.
Thanks for usefull advices.
  • Anonymous

     

    Try this

     

    email =
    MAXX ( TOPN ( 1, RELATEDTABLE ( LastLogin ), [Time Stamp], DESC ), [Email] )
    

5 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    Anonymous

    Hi

     

    Try this

     

    email =
    VAR login = Customer[Last login]
    RETURN
        CALCULATE ( MAX ( 'Last login'[Email] ), 'Last login'[Timestamp] = login )
    
    • Anonymous's avatar
      Anonymous
      Not applicable

      Does not work only blanks in entire column

      • Zubair_Muhammad's avatar
        Zubair_Muhammad
        Community Champion

        Anonymous

         

        By which field are the tables related?

         

        Can you show a snapshot?