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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
AnonymeC
Regular Visitor

[Q] Enhancements of this formula? (use of filter function without specifying the value?)

Hello,

 

Hope you can help me on this.

Here is an example of the database:

2 different type: Food/Non food

4 different sub types (Meat, Vegetables, Clothes, Electronics)

 

Article codeTypeSub-TypeBrandSalesCustom column (result)
00001FoodMeatXXX30=30+50=80
00002FoodVegetablesXXX4070
00003Non foodClothesXXX10115
....FoodMeatXXX5080
....Non foodClothesXXX15115
....Non foodElectronicsXXX22
....Non foodClothesXXX90115
00008FoodVegetablesXXX3070

 

My issue is the following. I am working on the Power Pivot editor and want to add a new custom column that I will call "result"). At the moment I did not manage to reach the wanted result, I am using a formula that calculates the sum of sales with a filter on a specific sub-type.

 

Current formula I am using is: = CALCULATE( SUM( My_Worksheet[Sales]), FILTER( My_Worksheet, My_Worksheet[Sub-Type]="Meat"))

 

Then I repeat the same formula for all different sub types, only changing the filter part ( My_Worksheet[Sub-Type]= "Vegetables", "Clothes" ...).

 

So I have several added columns, each for one specific sub type. Problem is it lacks flexibility, for example if there is a change of naming in the database and "Clothes" become "Cloth" then the formula won't work because I am calling a specific name. Is there a way to do this operation of sum per sub-types, without calling/filtering directly one Sub-Type?

 

Hope it is clear, many thanks in advance.

1 ACCEPTED SOLUTION

I managed to find something that worked:

 

= CALCULATE( SUM( MyWorksheet[Sales]), ALLEXCEPT( MyWorksheet, MyWorksheet[Sub-Types]))

 

This gives the correct Sub total for each row (sales per sub type).

View solution in original post

2 REPLIES 2
AnonymeC
Regular Visitor

To make the issue simpler:

 

What I have:

 

CodeSub-typeSales
1Meat10
2Meat50
3Vegetables30

 

What I want:

 

CodeSub-typeSalesSales per sub type
1Meat1060
2Meat5060
3Vegetables3030

 

(aim in the end is to calculate impact and weight of each sub-type)

I managed to find something that worked:

 

= CALCULATE( SUM( MyWorksheet[Sales]), ALLEXCEPT( MyWorksheet, MyWorksheet[Sub-Types]))

 

This gives the correct Sub total for each row (sales per sub type).

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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