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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Exclude current row from calculation

Hi. I need to do the following. I have a table of, say, products sold. Each row shows the selling price. It also shows the profit (selling price minus cost.) The bottom of the table shows the total profit % (gross profit %). That's the total profit divided by the total revenue (selling price). The table also shows the the GP% for each individual row. What I now need is to add another column to show what the total GP% would be if i were to exclude the current row from the sales transactions. Is there a way to accomplish this and at any level of granularity?

itemRevenue GP$ GP%Total GP% without current item
item1        1,000            90090.0%54%
item2        2,000        1,20060.0%60%
item3        3,000        1,50050.0%70%
Total GP%  60% 
11 REPLIES 11
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Has your problem been solved?

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

Hi, @v-lionel-msft . Thanks so much. Your solution works. However, it works at one level only. I needed it to work for each level in the hierarchy as in the below table. Thanks so much for your efforts!

yasbos_0-1622844298565.png

 

Anonymous
Not applicable

Hi, @v-lionel-msft . Sorry, I noted below that I am on vacation. I can't actually verify right now because I do not have the work laptop. I promise to verify and let you know by the end of the weekend. Thank you so much for your caring.

v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

v-lionel-msft_0-1622426606836.png

Please refer to my .pbix file.

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

Thanks @v-lionel-msft. I'm away from work now. I will review and will get back to you by the end of the week.

Anonymous
Not applicable

You could try:

ExCurrentRow = let tbl = PriorStepName, ThisItem = each [ItemID],
Ex = Table.SelectRows(tbl, each [ItemID] <> ThisItem),
RevEx = List.Sum(Ex[Revenue]),

GPEx = List.Sum(Ex[GP$])

in

Table.AddColumn(PriorStepName, "GPExCurrentRow", each GPEx / RevEx)

 

--Nate

Anonymous
Not applicable

Thanks @Anonymous . Your solution seems to be using M Query. I need this to work at the visual level. Thanks so much for your response.

Anonymous
Not applicable

Thanks @Fowmy  GP$ is going to be a simple measure: revenue - cost. Revenue is a column. It's a visual. 

Fowmy
Super User
Super User

@Anonymous 
Is this a Table Visual or a table in the model?
Are Revenue and GP$ are measures or columns? 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy  and @Anonymous . I kind of got something working there. I'm yet to test it for multiple granularity levels. However, as you can see from the screen grab, the total at the bottom of GP_Impact% is wrong. The way I got it to work so far is by doing the calculation for avery row twice--once using the all() function and another without it and then dividing the two.

yasbos_0-1622057472223.png

 

Anonymous
Not applicable

Thanks @Fowmy  GP$ is going to be a simple measure: revenue - cost. Revenue is a column. It's a visual. Also, I'm trying to make this solution work at any granularity. For instance, if, say, I have multiple aggregation levels, like, product segment that has many items. What will the result be if i were to drill up to the product segment? And, say, now there is even one more level, say, salesperson that has many segments, what will the result at that level? Thanks!

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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