Reply
avatar user
Anonymous
Not applicable

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.
1 ACCEPTED SOLUTION

@Anonymous

 

Try this

 

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

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

Hi

 

Try this

 

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

Does not work only blanks in entire column

@Anonymous

 

By which field are the tables related?

 

Can you show a snapshot?

avatar user
Anonymous
Not applicable

Customer(ID)

Last login(Customer ID, Email, Timestamp)

@Anonymous

 

Try this

 

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

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)