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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
arca123
Advocate I
Advocate I

Determining order of sale based on dates for unique customers

Hi all!

I am trying to determine the order of events based on dates. I have an identifier column that says if it’s the first event or last event. But I am clueless on how to determine anything in between. Would you have any suggestions for me?
Sample table I’m working with.

ClientIDPriceDateFirstSaleLastSale
15001.01.202301.01.202312.05.2023
13024.04.202301.01.202312.05.2023
15527.04.202301.01.202312.05.2023
18012.05.202301.01.202312.05.2023
21527.11.202227.11.202201.04.2023
24005.02.202327.11.202201.04.2023
25010.03.202327.11.202201.04.2023
23501.04.202327.11.202201.04.2023

 

I am expecting to write a measure or a new column that would identify whether a certain row contain data for 2nd, 3rd, etc sale. 

Would you please be able to help me with an idea that could solve this?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could do it either as a column or as a measure

Rank Column = 
RANK(, ALL( 'Table'[ClientID], 'Table'[Date] ), 
ORDERBY( 'Table'[Date], ASC), 
PARTITIONBY('Table'[ClientID]) )

Rank Measure = 
RANK(, ALLSELECTED( 'Table' ), 
ORDERBY( 'Table'[Date], ASC), 
PARTITIONBY('Table'[ClientID]) )

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

You could do it either as a column or as a measure

Rank Column = 
RANK(, ALL( 'Table'[ClientID], 'Table'[Date] ), 
ORDERBY( 'Table'[Date], ASC), 
PARTITIONBY('Table'[ClientID]) )

Rank Measure = 
RANK(, ALLSELECTED( 'Table' ), 
ORDERBY( 'Table'[Date], ASC), 
PARTITIONBY('Table'[ClientID]) )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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