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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

 

2 ACCEPTED SOLUTIONS
Tahreem24
Super User
Super 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.

 
 

 

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

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

V-lianl-msft
Community Support
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] ) )
)

test_filter_multi.PNG

 

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

 

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
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] ) )
)

test_filter_multi.PNG

 

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

 

Tahreem24
Super User
Super 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.

 
 

 

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

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
amitchandak
Super User
Super User

Try like

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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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