Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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!
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
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
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:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
What exact end result are you expecting?
@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.
Yes, the lowest in the set of work orders
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!