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

View all the Fabric Data Days sessions on demand. View schedule

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors