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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.