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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
atifbutt
Frequent Visitor

If condition with max date

Hi,

 

I'm building dashboard in Direct Query mode.

 

Data = Asatdate, UserID, Name, Ethnicity

 

I'd like to create a oclumn "Ethnicity Type" and to put values from Ethnicity column if the UserID field is not duplicate, if it is duplicate then put the latest value for Ethnicity by date.

 

Thank you in advance for the help.

 

Thanks

Atif

1 ACCEPTED SOLUTION

Thanks for replying Xiaoxin. I've found the solution via sql query :).

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @atifbutt,

 

Please share some sample data for test and coding formula.

 

Regards,

Xiaoxin Sheng

Thanks for replying Xiaoxin. I've found the solution via sql query :).

Could you kindly post the SQL solution?

 

Thanks

Select field1,field2,field3
from (select field1,field2, field3,
row_number() over (partition by employeenumber order by (datefield "to pick the latest record") desc) as rn from tablename) as T
Where RN = 1

Thank you so much

Select field1,field2,field3
from (select field1,field2, field3,
row_number() over (partition by employeenumber order by (datefield "to pick the latest record") desc) as rn from tablename) as T
Where RN = 1

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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