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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
user5341567
Frequent Visitor

How to count/group orders by customers in sequential order?

Hi all,

 

I have something which I thought would be a relatively easy solution, but I haven't been able to find any posts or a way to successfully do this after doing a ton of research. Has anyone run into this before?

 

I have a table with order number, customer number, and transaction date, and I need to count/group the number of orders per customer in sequential order, based on order date. E.g., for a customer number, if they have placed 4 orders, I'd expect to see 1, 2, 3, 4 next to the order number for a particular customer.

 

Here is an example dataset - hoping to calculate the 'Orders' column:

user5341567_0-1733848165353.png

 

Thank you so much for looking into this! Any input is greatly appreciated.

1 ACCEPTED SOLUTION

Try changing it to

Num order =
RANK (
    DENSE,
    ALL ( 'Table'[Order number], 'Table'[Customer] ),
    ORDERBY ( 'Table'[Order number], ASC ),
    PARTITIONBY ( 'Table'[Customer] ),
)

View solution in original post

5 REPLIES 5
v-jialongy-msft
Community Support
Community Support

Hi @user5341567 

This is my sample data:

vjialongymsft_0-1733898170194.png

 
You can get the result you want by using the following calculate column:

Column = RANKX(FILTER(ALL('Table'),'Table'[CustomerNumber] = EARLIER('Table'[CustomerNumber])),'Table'[OrderNumber],,ASC,Dense)

 

Result:

vjialongymsft_1-1733898245662.png

 

 

 

 

 

 

 

Best Regards,

Jayleny

 

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

 

 

johnt75
Super User
Super User

You could create a column like

Num order =
RANK (
    DENSE,
    ALL ( 'Table' ),
    ORDERBY ( 'Table'[Order number], ASC ),
    PARTITIONBY ( 'Table'[Customer] ),
)

Thank you so much for your response! I got a Circular Dependency error unfortunately - perhaps because I sometimes have several of the same order number? 

Try changing it to

Num order =
RANK (
    DENSE,
    ALL ( 'Table'[Order number], 'Table'[Customer] ),
    ORDERBY ( 'Table'[Order number], ASC ),
    PARTITIONBY ( 'Table'[Customer] ),
)

That worked perfectly. Thank you for your response!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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