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
MattLink
New Member

Count against multiple criteria and divide against another column value against a single row

Hi All,

 

Hoping for some assistance please.  We have work orders that engineers attend to.  The value of the work is held against the work order.  Each work order could have multiple bookings.  So i need to count the number of eligible bookings (based on status) and then divide this number by the value of the work oder.  This is to provide us with accurate daily forecast figures per each engineer.

 

Hopefully the below example better depicts what I am trying to achieve, with the Booking Value being a custom calculated column.  

 

MattLink_1-1652689396212.png

 

At the moment if i use the work order value it presents an incorrect result.

 

Any help you can provide on any forumla or DAX I can use to get the desired result will be greatly appreciated.

 

Thank you

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @MattLink 
New Measure 

Booking Value =
VAR WorkIdAndStatus =
    CALCULATETABLE (
        TableName,
        ALLEXCEPT ( TableName, TableName[Work Order ID], TableName[Booking Status] )
    )
VAR NumberOfBookings =
    COUNTROWS ( WorkIdAndStatus )
VAR OrderValue =
    MAXX ( WorkIdAndStatus, TableName[Work Order Value] )
RETURN
    IF (
        SELECTEDVALUE ( TableName[Status] ) = "Completed",
        DIVIDE ( OrderValue, NumberOfBookings )
    )

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @MattLink 
New Measure 

Booking Value =
VAR WorkIdAndStatus =
    CALCULATETABLE (
        TableName,
        ALLEXCEPT ( TableName, TableName[Work Order ID], TableName[Booking Status] )
    )
VAR NumberOfBookings =
    COUNTROWS ( WorkIdAndStatus )
VAR OrderValue =
    MAXX ( WorkIdAndStatus, TableName[Work Order Value] )
RETURN
    IF (
        SELECTEDVALUE ( TableName[Status] ) = "Completed",
        DIVIDE ( OrderValue, NumberOfBookings )
    )

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!

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.