Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

SUM with with multiple filtering

Hello Gang,

 

I hope you are all doing well in these difficult times. 

I have an issue creating a column formula. I want to sum the number of sales (in a column) but I would like to exclude some specific cases:

 

example data:

DivisionVendor NbrLocationSales
X44444454
Y40004005
X44004456
Z50003004

 

 

I would like in these examples to sum the Sales made but to exclude lines that have Division=X, Vendor Nbr=4444 and Location=445. Meaning it should not count the first line but the three others as the third one don't have the three parameters to exclude it. The result would be 15 in this example. Would it be possible to add more cases to exclude?

 

Best regards and stay safe,

 

Marc Dahlgren

 

  • Anonymous ,

    I will suggest you to create one more column "Miscellenous" and enter first value as NULL or BLANK and keeping some values in rest of the rows. After the create create simple DAX Measure to achieve your requirement:

    Measure = CALCULATE(sum(Table[Sales]),Table[Misc.]<>BLANK())
     
    So that above measure will skip blank Misc column record which would be your first record while adding rest of record by including third row of Division X.
     
    Your table structure would be like below:
    Division Vendor Nbr Location Sales Misc
    X 4444 445 4  
    Y 4000 400 5 1
    X 4400 445 6 2
    Z 5000 300 4 3

     

    Don't forget to give thumbs up 👍 and accept this as a solution if it helped you.

     
     

     

  • Hi Anonymous ,

     

    Please try the DAX below:

    Column 2 =
    IF (
        'Table'[Location] = 445
            && 'Table'[Division] = "X"
            && 'Table'[Vendor Nbr] = 4444,
        0,
        CALCULATE ( SUM ( 'Table'[Sales] ), ALLSELECTED ( 'Table'[Sales] ) )
    )

     

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

     

3 Replies

  • Try like

    calculate(sum(table[Sales]),table[Vendor Nbr]<>4444, table[Location]<>445)

     

  • Anonymous ,

    I will suggest you to create one more column "Miscellenous" and enter first value as NULL or BLANK and keeping some values in rest of the rows. After the create create simple DAX Measure to achieve your requirement:

    Measure = CALCULATE(sum(Table[Sales]),Table[Misc.]<>BLANK())
     
    So that above measure will skip blank Misc column record which would be your first record while adding rest of record by including third row of Division X.
     
    Your table structure would be like below:
    Division Vendor Nbr Location Sales Misc
    X 4444 445 4  
    Y 4000 400 5 1
    X 4400 445 6 2
    Z 5000 300 4 3

     

    Don't forget to give thumbs up 👍 and accept this as a solution if it helped you.

     
     

     

  • V-lianl-msft's avatar
    V-lianl-msft
    Community Support

    Hi Anonymous ,

     

    Please try the DAX below:

    Column 2 =
    IF (
        'Table'[Location] = 445
            && 'Table'[Division] = "X"
            && 'Table'[Vendor Nbr] = 4444,
        0,
        CALCULATE ( SUM ( 'Table'[Sales] ), ALLSELECTED ( 'Table'[Sales] ) )
    )

     

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