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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

need help identifying customers first, 2nd and so on orders

Hi,

 

i have a data set which contains customer orders and im trying to find a way to identify the customers purchases from their 1st order to their latest but i cant find a solution to the problem and i was wondering if you could help me.

Our data set contains customer id, order id, article id and order date among other things

 

i used to solution from Solved: Customer 1st vs 2nd order behaviour ( excluding ze... - Microsoft Power BI Community  as in i used the formula

= RANKX(FILTER(Fact_table,Fact_table[business_partner_code]=EARLIER(Fact_table[business_partner_code])),Fact_table[demand_date_id],,ASC)

to see which orders were their first ones but when it comes to the second and third order it adds on to that depending on how much was in the first order. 

 

as an example here is a customer who bought 4 items his first purchase and in his 2nd purchase he bought 6 items.

bratlaz_0-1624886591101.png

is there a solution so the second order gets a value of 2 and so on?

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Try "Dense" in Rank function. I update your code.

New calculated column:

New Rank = 
RANKX(FILTER(Fact_table,Fact_table[business_partner_code]=EARLIER(Fact_table[business_partner_code])),Fact_table[demand_date_id],,ASC,Dense)

Result is as below.

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
arrowav36
Frequent Visitor

Hi,

Its showing this error while I am running this query can you please help me to resolve this?

Error : EARLIER/EARLIEST refers to an earlier row context which doesn't exist.

 

I am trying to find the customers 1st, 2nd, 3rd and so on.. purchases, in front of each order I wanted to write that which number'th of order it is for that particular customer.

Please help me with the solution.

v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Try "Dense" in Rank function. I update your code.

New calculated column:

New Rank = 
RANKX(FILTER(Fact_table,Fact_table[business_partner_code]=EARLIER(Fact_table[business_partner_code])),Fact_table[demand_date_id],,ASC,Dense)

Result is as below.

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Hi,

Its showing this error while I am running this query can you please help me to resolve this?

Error : EARLIER/EARLIEST refers to an earlier row context which doesn't exist.

 

I am trying to find the customers 1st, 2nd, 3rd and so on.. purchases, in front of each order I wanted to write that which number'th of order it is for that particular customer.

Please help me with the solution.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.