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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
HansBaeten
Frequent Visitor

Count first occurence of order when state is equal to a value

Hi,

 

I have a dataset like this (only the first 4 columns, last column is only to indicate if I need the row in my final result or not):

 

DateTimeOrderStatus To count
4/11/201921:001Started Yes
4/11/201922:001Hold  
4/11/201923:001Started  
5/11/20195:001Started  
5/11/20195:301Started  
5/11/20196:451Stopped  
3/11/201922:302Started Yes
3/11/201923:002Started  
4/11/20191:302Started  
4/11/20193:002Started  
3/11/201923:003Started Yes
4/11/20191:303Started  
4/11/201921:004Started Yes
4/11/201922:004Hold  
4/11/201923:004Started  
5/11/20195:004Started  
5/11/20195:304Started  
5/11/20196:454Stopped  

 

I want to be able to count the number of orders by day, but only the first occurence of the order + when the state = Started. The desire result should look like:

 

DateCount
3/11/20192
4/11/20192
5/11/20190

 

Who can help me?

 

Thanks.

 

Regards,

Hans

 

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

@HansBaeten ,

 

Could you please explain the logic of "first occurence of the order"?

 

Regards,

Jimmy Tao

@v-yuta-msft,

 

I only want to count records where the state "started" appeared for the first time on an order level.

 

In my example, state "started" appeared for the first time at 4/11/2019 21:00 for order 1. From this moment on, I'm no longer interested in the other states "started" of the same order.

 

Actually, I want to see when an order was actually started. The order keeps this state until there is a change of state.

In case of order 1: if I do a simple count by day, I will have a result on 4/11 and 5/11 (both days are having a state started). But an order can be started only once.

 

Hope this clarifies my requirement?

 

Thanks in advance for your help.

 

Regards,

Hans

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.