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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
LV17
New Member

Is it possible to count in order by date?

Hello,

 

I am new to Power BI and  am wondering if there is a function in Power BI that can give the same result as regular Excel. I want to count the number of orders of a customer in order by date. I've added an example of my data from excel.

 

As you can see the total number of orders of a customer can be calculated in excel by the following function (this is for order on march 3th): =COUNT.IF(C:C;C8). And in Power BI I believe this can be achieved with the DISTINCTCOUNT function.

 

But for the nth order I use =COUNT.IF(C$2:C8;C8) in excel (this is for order on march 3th). So I get the value for the first, second, third, etc. order of a particular customer (because the column is sorted on the date). Now I am wondering if can achieve the same result in Power BI. And if so, how?

 

Schermafbeelding 2022-12-08 om 11.16.55.png

 

Thanks in advance!

 

Lars

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

Hi , @LV17 

According to your description, you want to calcualte the [nth Order] and the [Total no. Order] column in Power BI . Right?

Here are the steps you can refer to :
(1)My test data is the same as yours.

(2)We can click "New Column" and enter the below Dax code to create two calculated columns:

vyueyunzhmsft_0-1670550553332.png

nth Order = var _cur_CustomerID=[Customer ID]
var _curDate = [Date]
var _t = FILTER('Table', 'Table'[Date]<= _curDate && 'Table'[Customer ID] =_cur_CustomerID)
return
COUNTROWS(_t)
Total no. Orders = var _curCustomerID= [Customer ID] 
var _t = FILTER( 'Table','Table'[Customer ID]=_curCustomerID)
return
COUNTROWS(_t)

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1670550583755.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @LV17 

According to your description, you want to calcualte the [nth Order] and the [Total no. Order] column in Power BI . Right?

Here are the steps you can refer to :
(1)My test data is the same as yours.

(2)We can click "New Column" and enter the below Dax code to create two calculated columns:

vyueyunzhmsft_0-1670550553332.png

nth Order = var _cur_CustomerID=[Customer ID]
var _curDate = [Date]
var _t = FILTER('Table', 'Table'[Date]<= _curDate && 'Table'[Customer ID] =_cur_CustomerID)
return
COUNTROWS(_t)
Total no. Orders = var _curCustomerID= [Customer ID] 
var _t = FILTER( 'Table','Table'[Customer ID]=_curCustomerID)
return
COUNTROWS(_t)

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1670550583755.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors