Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
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 )
Anonymous
Not applicable

Does not work only blanks in entire column

@Anonymous

 

By which field are the tables related?

 

Can you show a snapshot?

Anonymous
Not applicable

Customer(ID)

Last login(Customer ID, Email, Timestamp)

@Anonymous

 

Try this

 

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors