# Excess Inventory summary not correct

**URL:** https://pug.phocassoftware.com/t/excess-inventory-summary-not-correct/1014
**Category:** Ask the Community
**Created:** [May 2, 2019, 8:11pm UTC](https://pug.phocassoftware.com/t/excess-inventory-summary-not-correct/1014 "2019-05-02T20:11:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![rsavage16](https://sea1.discourse-cdn.com/flex015/user_avatar/pug.phocassoftware.com/rsavage16/32/392_2.png) [@rsavage16](https://pug.phocassoftware.com/u/rsavage16)
#### Post date: [May 2, 2019, 8:11pm UTC](https://pug.phocassoftware.com/t/excess-inventory-summary-not-correct/1014/1 "2019-05-02T20:11:36Z")

</div>

Hello, we are trying to build a dashboard for our buyers and one of the widgets is for excess inventory. Thanks to the PUG we were able to use a formula to remove negative values (^case when{a}-{b}\< 0 then ‘0’ else {a}-{b} end).

When we look at the excess by item/sku level it looks great. When we group by the dimension by buyer, the total excess is showing zero for most of them.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/phocassoftware/original/1X/16ce20424a09a69dbf2da5480a7bd02829fbd7ca.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/phocassoftware/original/1X/d7be65ff9a487c7f39142e296461c808c1dc3aa0.png)

The excess is not zero because they do have items with an excess value.

I

 ![image](https://us1.discourse-cdn.com/flex015/uploads/phocassoftware/original/1X/3861b596aa35a3b764afa79e591af78e86ab816b.png)

I know the problem is in the formula. We need to eliminate all negative $ amount at the sku level prior to summarizing by buyer.

Do I make sense?

---

<div class="post-metadata">

### Author: ![StuartH](https://sea1.discourse-cdn.com/flex015/user_avatar/pug.phocassoftware.com/stuarth/32/394_2.png) [@StuartH](https://pug.phocassoftware.com/u/StuartH)
#### Post date: [May 3, 2019, 7:27am UTC](https://pug.phocassoftware.com/t/excess-inventory-summary-not-correct/1014/2 "2019-05-03T07:27:20Z")

</div>

Have you tried putting the CASE WHEN in the advanced search area instead of as a column in custom?

Not sure on the hierarchy of how and when calculations are applied but I had a report where I joined effectively two streams and when I used the Custom view it waited till the end, but in Advanced Search I could filter each stream independantly.

---

<div class="post-metadata">

### Author: ![rsavage16](https://sea1.discourse-cdn.com/flex015/user_avatar/pug.phocassoftware.com/rsavage16/32/392_2.png) [@rsavage16](https://pug.phocassoftware.com/u/rsavage16)
#### Post date: [May 3, 2019, 9:30pm UTC](https://pug.phocassoftware.com/t/excess-inventory-summary-not-correct/1014/3 "2019-05-03T21:30:11Z")

</div>

Its a calculated field, can you do that in the advanced search?

---

<div class="post-metadata">

### Author: ![StuartH](https://sea1.discourse-cdn.com/flex015/user_avatar/pug.phocassoftware.com/stuarth/32/394_2.png) [@StuartH](https://pug.phocassoftware.com/u/StuartH)
#### Post date: [May 7, 2019, 1:55pm UTC](https://pug.phocassoftware.com/t/excess-inventory-summary-not-correct/1014/4 "2019-05-07T13:55:12Z")

</div>

Hmm, seems an odd one - I’ve replicated your report and can see that the column doens’t total as expected - maybe there’s a thing where columns with CASE WHEN in don’t total - I think the 0 is being treated as text and not a number and therefore breaks the sum.

However, if you could live with only seeing those items where there is an excess then you could do the following:

1. Make the formula in Custom just A - B

 ![image](https://us1.discourse-cdn.com/flex015/uploads/phocassoftware/original/1X/8862db2f254f07479ef4f2dcf7ce31e3b4a2c4b5.png)

1. Use advanced filter to filter only those records where the result of that sum is actually a positive number.

![image](https://us1.discourse-cdn.com/flex015/uploads/phocassoftware/original/1X/9ac5c50d2cd38690cfe790c8017b7feeb4eac53f.png)

You should then be able to use the Nested mode to cut and dice that as you need

---

<div class="post-metadata">

### Author: ![rsavage16](https://sea1.discourse-cdn.com/flex015/user_avatar/pug.phocassoftware.com/rsavage16/32/392_2.png) [@rsavage16](https://pug.phocassoftware.com/u/rsavage16)
#### Post date: [May 16, 2019, 1:52am UTC](https://pug.phocassoftware.com/t/excess-inventory-summary-not-correct/1014/5 "2019-05-16T01:52:35Z")

</div>

Sorry for the delay! We’ve decided that we will get a Phocas consultant to help us with this and several other inventory and GL reports. Thanks for you help, i will keep this in mind!
