Forum Discussion
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:
| Division | Vendor Nbr | Location | Sales |
| X | 4444 | 445 | 4 |
| Y | 4000 | 400 | 5 |
| X | 4400 | 445 | 6 |
| Z | 5000 | 300 | 4 |
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
- amitchandakSuper User
Try like
calculate(sum(table[Sales]),table[Vendor Nbr]<>4444, table[Location]<>445) - Tahreem24Super User
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-msftCommunity 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.