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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
SriKandimalla
Helper I
Helper I

Determine an attribute with duplicates, and sorting by the latest date using DAX column

Hello PBI Comunity,

 

I am trying to solve the following criteria:[Latest name] is my target DAX column.
I need to check if a name is duplicate, then check all the dates for that name, only the latest date will get 1 in the target column. The rest will have 0      

Note: If the name has multiple dates like alice, only one date have to get 1.MockData.png

 

 This is my data set                                                                                                                          https://drive.google.com/file/d/1n6xIE5fXunz1hMsE1po6INoc0aAQRTtN/view?usp=sharing               

 

TIA,

Sri

2 REPLIES 2
HotChilli
Super User
Super User

Step 1: In Power Query, sort the data by name first and then date

2. Group the data by name.  Use 'All rows' as the new column.

3. Add an Index to each grouping of name with:

 

Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([All], "Ind", 1, 1))

 

4. Expand the Index column and remove the ALL column.  You should get this:

 

Annotation 2020-03-31 024139.png

5. a) You can add the column in Power Query (I'll leave you to figure that one out)  OR

b) Use this DAX

 

 

Column = IF(CALCULATE(MAX(dataNames[Custom.Ind]), ALLEXCEPT(dataNames,dataNames[name])) = dataNames[Custom.Ind], 1, 0)

 

 

 

 

Hello @HotChilli ,

I appreciate your response!
However, I cannot do this in the query editor, I have many columns unlike the sample data

Is there a way to do this in DAX without the help of query editor?

Thanks,

Sri

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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