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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mbbui0721
New Member

IF SUM Statement DAX

Hello,

 

I'm fairly new to DAX. I'm tying to compare the TYPE of just Work Order Warranty and Warranty Transaction based on the total QTY of the item. If the Sum of QTY of Work Order Warranty is greater than Warranty Transactions then out "Fullfilled" else "Pending" as a new column. 

 

 

ORGDateItemTRX ValueQTYTYPE
11/1/2021A05178741054158Work Order Annual/Modular/Parts Rebuild
21/2/2021A05280020815975Work Order Repair
11/3/2021A05603263725.58Work Order Warranty
21/4/2021A05603263726.75Warranty Transaction
11/5/2021A0517874105418.97Work Order Annual/Modular/Parts Rebuild
21/6/2021A0528002081598.878Work Order Annual/Modular/Parts Rebuild
11/7/2021A05603263729.625Work Order Repair
11/8/2021A056032637210.378Work Order Warranty
      
1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@mbbui0721,

 

Try this calculated column. I'm not sure if you want "Pending" for every row that is not "Fulfilled", or for every row that is not "Fulfilled" and TYPE = "Work Order Warranty" or "Warranty Transaction". The DAX can be easily adjusted to accommodate either scenario.

 

Status = 
VAR vWorkOrderWarranty =
    CALCULATE (
        SUM ( Table1[QTY] ),
        ALLEXCEPT ( Table1, Table1[Item] ),
        Table1[TYPE] = "Work Order Warranty"
    )
VAR vWarrantyTransaction =
    CALCULATE (
        SUM ( Table1[QTY] ),
        ALLEXCEPT ( Table1, Table1[Item] ),
        Table1[TYPE] = "Warranty Transaction"
    )
VAR vResult =
    SWITCH (
        TRUE (),
        Table1[TYPE]
            IN { "Work Order Warranty", "Warranty Transaction" }
            && vWorkOrderWarranty > vWarrantyTransaction, "Fulfilled",
        Table1[TYPE]
            IN { "Work Order Warranty", "Warranty Transaction" }
            && vWorkOrderWarranty <= vWarrantyTransaction, "Pending"
    )
RETURN
    vResult

 

DataInsights_0-1628261280678.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@mbbui0721,

 

Try this calculated column. I'm not sure if you want "Pending" for every row that is not "Fulfilled", or for every row that is not "Fulfilled" and TYPE = "Work Order Warranty" or "Warranty Transaction". The DAX can be easily adjusted to accommodate either scenario.

 

Status = 
VAR vWorkOrderWarranty =
    CALCULATE (
        SUM ( Table1[QTY] ),
        ALLEXCEPT ( Table1, Table1[Item] ),
        Table1[TYPE] = "Work Order Warranty"
    )
VAR vWarrantyTransaction =
    CALCULATE (
        SUM ( Table1[QTY] ),
        ALLEXCEPT ( Table1, Table1[Item] ),
        Table1[TYPE] = "Warranty Transaction"
    )
VAR vResult =
    SWITCH (
        TRUE (),
        Table1[TYPE]
            IN { "Work Order Warranty", "Warranty Transaction" }
            && vWorkOrderWarranty > vWarrantyTransaction, "Fulfilled",
        Table1[TYPE]
            IN { "Work Order Warranty", "Warranty Transaction" }
            && vWorkOrderWarranty <= vWarrantyTransaction, "Pending"
    )
RETURN
    vResult

 

DataInsights_0-1628261280678.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.