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
A_B_M
New Member

Add custom column to identify if date and Id are unique

Hi,

I have a large dataset of product sales for the last 5 years that creates a new row if the customer bought more than one product in the sale. I want to be able to add a custom column (Orders) that will place a 1 next to the first row with a matching Order Date and Customer ID and then a null for any repeat rows for that order. 

 

For example

 

Order DateCustomer IDOrders
2/2/20241212121
2/2/2024121212null
2/2/20241234561
3/2/20244444441
3/2/20243434341
3/2/20241212121
3/2/2024444444nulll

 

What is the easiest way to do this? 

 

Thanks for your help,

A

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@A_B_M 

maybe you can try this

1. create an index column in PQ

11.PNG

 

2. use DAX to create a column

Column = if(ISBLANK(maxx(FILTER('Table','Table'[Order Date]=EARLIER('Table'[Order Date])&&'Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Index]<EARLIER('Table'[Index])),'Table'[Customer ID])),1)
 
or
 
Column = if(maxx(FILTER('Table','Table'[Order Date]=EARLIER('Table'[Order Date])&&'Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Index]<EARLIER('Table'[Index])),'Table'[Customer ID]))="",1)
 
12.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
ryan_mayu
Super User
Super User

@A_B_M 

maybe you can try this

1. create an index column in PQ

11.PNG

 

2. use DAX to create a column

Column = if(ISBLANK(maxx(FILTER('Table','Table'[Order Date]=EARLIER('Table'[Order Date])&&'Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Index]<EARLIER('Table'[Index])),'Table'[Customer ID])),1)
 
or
 
Column = if(maxx(FILTER('Table','Table'[Order Date]=EARLIER('Table'[Order Date])&&'Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Index]<EARLIER('Table'[Index])),'Table'[Customer ID]))="",1)
 
12.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.