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
Towerstar
New Member

Calculate sum for selected productnumbers and rest productnumbers

Hello,

I am looking for a formula to display in a stacked column chart my focus products and rest products.

Lets say I have 10 products. My focus  products are 1, 4, 7 and 9. My target is to get a formula where I see in the legend 1,4,7,9, rest. (and rest includes 2,3,5,6,8,10). 

 

I started like this.

Product Quantity 1, 4, 7, 9 =

CALCULATE(SUM('Rohdaten'[Quantity]), 'Rohdaten'[ProductID]="1") +

CALCULATE(SUM('Rohdaten'[Quantity]), 'Rohdaten'[ProductID]="4") +

CALCULATE(SUM('Rohdaten'[Quantity]), 'Rohdaten'[ProductID]="7") +

CALCULATE(SUM('Rohdaten'[Quantity]), 'Rohdaten'[ProductID]="9")

 

But now I dont know how i can caluclate the sum of the rest products and the formula is quite long. 

 

Do you have any tip how I can solve this problem in the best way? 

 

Thank you in advance. Your help is appreciated.

 

Best 

towerstar

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Towerstar ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1662010087751.png

You can create a slicer to select the products that need to be summed:

vjianbolimsft_1-1662010180653.png

Then create a measure to calculate the rest:

Rest = CALCULATE(SUM(Rohdaten[Quantity]),ALL(Rohdaten))-SUM([Quantity])

Add it to the chart:

vjianbolimsft_2-1662010245049.png

Open the data labels:

vjianbolimsft_4-1662010312264.png

 

Final output:

vjianbolimsft_3-1662010281012.png

Best Regards,

Jianbo Li

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

4 REPLIES 4
v-jianboli-msft
Community Support
Community Support

Hi @Towerstar ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1662010087751.png

You can create a slicer to select the products that need to be summed:

vjianbolimsft_1-1662010180653.png

Then create a measure to calculate the rest:

Rest = CALCULATE(SUM(Rohdaten[Quantity]),ALL(Rohdaten))-SUM([Quantity])

Add it to the chart:

vjianbolimsft_2-1662010245049.png

Open the data labels:

vjianbolimsft_4-1662010312264.png

 

Final output:

vjianbolimsft_3-1662010281012.png

Best Regards,

Jianbo Li

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

Towerstar
New Member

Hi Syk, 

 

thanks for your reply. It is just an example. In real its more than 100 products... I need the total quantity in my chart stacked by the focus products and rest products. How can I solve this problem with or in my formula? 

I would create a new column to indicate if a product is a focus product or not and base my measure off the new field. Or you can group the IDs into focus and rest groups but it really depends on what you can use to categorize the products (hopefully thats not a manual process?)

Syk
Super User
Super User

If you want the measure to be hardcoded specifically for those ids, one simpler way would be to use OR in your calculate expression

Product Quantity 1, 4, 7, 9 =
CALCULATE (
    SUM ( 'Rohdaten'[Quantity] ),
    'Rohdaten'[ProductID] = "1"
        || 'Rohdaten'[ProductID] = "4"
        || 'Rohdaten'[ProductID] = "7"
        || 'Rohdaten'[ProductID] = "9"
)

 

If you want to calculate that quantity on the fly, I'd suggest using a slicer on the report page where users can select which ID they'd like to see instead of creating a measure.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

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.