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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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