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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Remove Row Context in a Calculated Column

Hello. I need help with context in a calculated column. Unfortunately this needs to be a column, can't be a measure.

 

I have the following data:

 

Cod ClientSegmentProductVolume Sold
6001SupermarketPasta15
6001SupermarketCheese3
6001SupermarketBread2
6002DistributorPasta10
6002DistributorCheese1
6002DistributorBread0
6003SupermarketPasta13

6003

SupermarketCheese2

6003

SupermarketBread1

 

My challenge is to add a column with the value of pasta sold for the same cliente reapeted for all the lines of that client.

 

After that I'll need to get the SUM of all volume sold for clients in the same segment. 

Last I'll need a column with the SUM of volume sold of pasta for the same segment. 

 

The result expected:

 

Cod ClientSegmentProductVolume SoldVolume Pasta SoldVolume Sold SegmentVolume Pasta Sold Segment
6001SupermarketPasta15152828
6001SupermarketCheese315528
6001SupermarketBread215328
6002DistributorPasta10101010
6002DistributorCheese110110
6002DistributorBread010010
6003SupermarketPasta13132828

6003

SupermarketCheese213528

6003

SupermarketBread113328

 

 

I tried to use:

 

Volume Pasta Sold = CALCULATE(SUM(Volume Sold), FILTER(ALL(Product), Product = "Pasta"))

 

 

But it return blank spaces for products that are not pasta.

 

Thank you in advance for the help!

2 ACCEPTED SOLUTIONS
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Try these Calculated Columns

 

Volume of Pasta Sold = CALCULATE(SUM('Table'[Volume Sold]), FILTER( ALLEXCEPT('Table','Table'[Cod Client]), 'Table'[Product] = "Pasta"))

 

Volume of Pasta Sold Segment = CALCULATE(SUM('Table'[Volume Sold]),FILTER(ALLEXCEPT('Table','Table'[Segment]), 'Table'[Product] = "Pasta"))

 

 

Cannot understand the logic of the middle column calculation.

 

1.jpg

 

 

Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

View solution in original post

@Anonymous ,

This one worked for the formula you have given

 

 

Volume of pasta Sold 1 = CALCULATE(SUM(Sheet1[Volume Sold]),ALLEXCEPT(Sheet1,Sheet1[Cod Client]),Sheet1[Product]="Pasta")

 

 

 

Volume of pasta Sold Segment 1 = CALCULATE(SUM(Sheet1[Volume Sold]),ALLEXCEPT(Sheet1,Sheet1[Segment]),Sheet1[Product]="Pasta")

 

 

Volume Sold Segment1 = CALCULATE(SUM(Sheet1[Volume Sold]),ALLEXCEPT(Sheet1,Sheet1[Segment],Sheet1[Product]))

Please find attached file after signature

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Try these Calculated Columns

 

Volume of Pasta Sold = CALCULATE(SUM('Table'[Volume Sold]), FILTER( ALLEXCEPT('Table','Table'[Cod Client]), 'Table'[Product] = "Pasta"))

 

Volume of Pasta Sold Segment = CALCULATE(SUM('Table'[Volume Sold]),FILTER(ALLEXCEPT('Table','Table'[Segment]), 'Table'[Product] = "Pasta"))

 

 

Cannot understand the logic of the middle column calculation.

 

1.jpg

 

 

Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

amitchandak
Super User
Super User

@Anonymous , did not get is completely  you might have to use something like this

Volume Pasta Sold = CALCULATE(SUM(Volume Sold), ALLEXCEPT(Product))

 

refer

https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/

https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandek, almost. The problem is, I don't want to ignore the product. I want to repeat the volume of past sold for that client, in all the lines for that same client.

@Anonymous ,

This one worked for the formula you have given

 

 

Volume of pasta Sold 1 = CALCULATE(SUM(Sheet1[Volume Sold]),ALLEXCEPT(Sheet1,Sheet1[Cod Client]),Sheet1[Product]="Pasta")

 

 

 

Volume of pasta Sold Segment 1 = CALCULATE(SUM(Sheet1[Volume Sold]),ALLEXCEPT(Sheet1,Sheet1[Segment]),Sheet1[Product]="Pasta")

 

 

Volume Sold Segment1 = CALCULATE(SUM(Sheet1[Volume Sold]),ALLEXCEPT(Sheet1,Sheet1[Segment],Sheet1[Product]))

Please find attached file after signature

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors