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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

DAX MIN Count by Grouping Difficulty

Hello DAX pros!

 

I have what seemed to me like an easy calculation but I'm running into issues. I have below a dummy sample of sales agreements our company uses. Each one has a date, sales agreement number, one or more work orders associated to it, and a completion date if completed otherwise it is null. I have a requirement where I need to calculate the number of completed work orders where the first work order completed for each sales agreement would get a 0 in the column, and all other ones would get a 1. The work orders circled in red below would get a 1 since they are the first work order in the grouping. Reason for the grouping is because commission percentage is different based on the first completed work orders and subsequent work orders. Does anyone have any experience doing this? Any help would be appreciated! 

 

Thanks in advance! 

 

Untitled.png

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

 

Best Regards

Allan

v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

f1.png

 

You may create a measure as below.

Count = 
CALCULATE(
    DISTINCTCOUNT('Table'[Work Order]),
    FILTER(
        ALL('Table'),
        'Table'[Sales Agreement]=SELECTEDVALUE('Table'[Sales Agreement])&&
        'Table'[Work Order]<=SELECTEDVALUE('Table'[Work Order])&&
        'Table'[Work Order Completion Date]<>BLANK()
    )
)

 

Result:

f2.png

 

Best Regards

Allan

 

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

Ashish_Mathur
Super User
Super User

Hi,

What exact end result are you expecting?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@Anonymous what defines the first work order in an agreement, the lowest number of the work order within that agreement?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Yes, the lowest in the set of work orders

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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