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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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.

watkinnc
Super User
Super User

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


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
Anonymous
Not applicable

Thanks @watkinnc . 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 @watkinnc . 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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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