Finding Conditional sum to determine the Units Sold Units Remaining in inventory sheet - google-sheets

I have a Google sheet Here is the spreadsheet which is used for determining the inventory at FIFO basis. I have different products that come into my stock and I sell them.
I bring in fruits and record entries in A to E columns using simple formulas. But the problem is here after the E columns from F to I. When the sale take place I increase the existing value in G1 and select E1, The formulas would dynamically display the selling price based on purchase price.
Say if I have sold 50 more apples then G1 becomes 550.
I am ok if the products are continuous like Green color (Apples), When the products are of different types they need to coined using SUMIFs or something else which I am not sure how to implement.
Please help to display based on yellow cells for entire table
Here is the
=MIN(C4,$G$1-SUM($F$3:F3))

Please see if this helps:
=IF(A4=$E$1,MIN(C4,$G$1-SUMIF($A$3:A3,$E$1,$F$3:F3)),0)
The formula is for F4 and needed to be copyed down.
It uses sumif for a product name + checks if current product is "apple" or one you've selected.

Related

Double (Nested) XLOOKUP with reverse search mode issue

I've created a profit/loss google sheet that allows me to price up a list of items for each project I'm working on (I've simplified it for the purpose of my issue I'm trying to solve). It works by referencing a master pricing sheet so that I can manage the current pricing from one location.
In the MasterCopy tab I'm importing the master pricing sheet for all my items. If you look at the first row, the first set of pricing for EUR, USD, AUD are my costs and the second set of those curriencies are my sell price.
https://docs.google.com/spreadsheets/d/1SE-FtDsJOblrlEpkxSwn3_L3MZ1VD6DNzTDlGTj0vCc/edit?usp=sharing
In the "Profit Loss" sheet I'm using a nested XLOOKUP formula. For columns F, G, and H the formula uses "1" for the search mode and for columns K, L, and M it is the same, but uses "-1" search mode so that it searches across the MasterCopy sheet headers in reverse.
XLOOKUP(F$2,MasterCopy!$1:$1,xlookup($A3,MasterCopy!$A:$A,MasterCopy!$1:$1000),,,1)
XLOOKUP(K$2,MasterCopy!$1:$1,xlookup($A3,MasterCopy!$A:$A,MasterCopy!$1:$1000),,,-1)
However, the issue I run into is that for some reason one of the column sets (EUR, USD, or AUD cost and sell) it will show the same pricing for the cost and sell columns for the corresponding currency. For example, cell L3 shows 1,025 USD, but the corresponding USD cost column also shows 1,025 USD, when it should actually be a value of 925 (which is correctly showing in the MasterCopy tab).
Any help would be really welcomed. I'm hoping it's a simple logic error, but just can't seem to get all the sets of pricing to show the correct values.
Edit 1
I reloaded the sheet and suddenly it's the AUD columns showing the same values. See image below
AUD columns showing same values
maybe just use the header 'AUD Sell' in Cell AR1 (MasterCopy)
AND
use this formula in Cell M3 (Profit Loss)
=XLOOKUP(M$2&" "&J$1,MasterCopy!$1:$1,xlookup($A3,MasterCopy!$A:$A,MasterCopy!$1:$1000),)
totally eliminating the search_mode which is causing this amiss.

I would like to Automatically sort a Google Sheet highest to lowest, then remove duplicate values

I have a google sheet that contains an inventory list that include manufacturer and model id's. Each line item contains a price and the amount the product is discounted below MSRP. I have the raw information dumping into a spreadsheet daily but I need the sheet to automatically sort the sheet by the make/model/highest discount value and then remove the duplicates (Removing all of the lower make/model/discount values). I could easily do this task manually but I am hoping to find a scaleable way to perform this tasks for many different lists.
To get UNIQUE Id's paste this formula in F2.
=UNIQUE(A2:A)
In G2 Paste this formula and drag down.
=IF(F2="",,SORTN(FILTER($B$2:$D,$A$2:$A=F2),1,,4,0,3,0))
Note: duplicates are highlighted in yellow and green

Trying to get the size (in %) of subcategories in a pivot

I am keeping track of my (stock) portfolio in Google Sheets, as follows:
category subcategory company amount
-------------------------------------------
health care diagnostics AA 100
health care diagnostics AB 50
materials mining BA 75
financials banks CA 30
financials insurers CB 35
financials banks CC 10
financials banks CD 40
financials hedge fund CE 5
health care equipment DA 50
But now I want to extract some statistics from this, and I'm using a Pivot. Specifically, I want to see:
the relative size of each category in the portfolio
the relative size of each subcategory in the portfolio
the relative size of each company in their subcategory
The first two I get done:
For instance, I can see that:
category financials has a relative size of 30% in the portfolio
subcategory diagnostics has a relative size of 37.97% in the portfolio
What is missing however, is the third column, see mockup below:
I can now see in the last column what the relative size of each company is in its subcategory:
Company CD is 50% of the subcategory banks
Company AB is 300.33% of the subcategory diagnostics
That last column however, is not calculated but added manually to show what output I am trying to get but am unable to.
Does anyone know how to have this last column as part of the Pivot?
Here is a link to the Google Sheet used: Pivot
Currently, there is no % by subtotal option in Google Sheets to show percentages against subtotals for the whole Pivot Table:
As a workaround, you can display the subtotal percentages by filtering the Pivot Table to display only one subcategory, for example:
Add Filter here and select subcategory:
Then select the desired field, for example, banks, and click OK.:
This should display the subtotal percentages like this:
Note: You can delete category field in Rows to make the Pivot Table cleaner.
You can also submit a feature idea request to Google Workspace, please see instructions on this site: Submit ideas for Google Workspace and Cloud Identity
So I found out there are two possible solution using calculated column and another using arrayformula.
Option 1: Use a duplicate pivot table. One issue of getPivotData function is that it will run in the table calculations stage so it will return empty result. So the solution was to have two clones of the pivot table. One will be used to retrieve the data and the other to retrieve the subtotal.
The formula to use would be
=amount/getpivotdata("amount",'Copy of Pivot'!$F$10, "category", category, "subcategory", subcategory)
Where amount, category, subcategory without the double quotes are values (references) filled by Google Sheets. While the double quoted ones are column names.
You also need to set summarize by to custom for it to work.
The only issue I found here is that I couldn't find a way to identify subtotal or total rows, they do have company value equal to the first record in the group. If anyone know how to know if I am rendering a subtotal, please let me know.
The second option is to use one pivot table only but reference original data.
=amount/SUM(QUERY($A$1:$D,"Select D Where A='"&category&"' AND B='"&subcategory&"'",false))
It still shares the same total rows though.
The last option will be the least robust. It would be using arrayformula but I don't have that ready at the moment. It is main issue is that changing the column orders or adding new columns will require to keep the position of the refenced columns and move the arrayformula columns. Not to mention, handling the empty cells in a category since data is grouped.

Summing cells which have certain value next to them AND a certain value is in another column

https://docs.google.com/spreadsheets/d/1xdB1Dl58aGsCOj1Xu1RZRB52Fn4RwbXDHlhuUDHZ1DU/edit?usp=sharing
I maintain spreadsheets for a sawmill. There are different suppliers and wood from them is split into different categories. What I want to do in the summary sheet, is to sum certain values from the Deliveries sheet, so I get an overview of how much of a certain kind of wood we received from a supplier.
Let's do it for "Alice" and "pine". How much pine has Alice brought in this month? I have no problem looking for every "pine" entry and summing it up, as demonstrated in the example, but I want only these pine entries, which are under "Alice" supplier entry. I assume I have to use sumifs(), but what complicates matters is that the "Alice" keyword often isn't straight to the left, because each separate truck is denoted by one supplier entry. Might sound complicated, but the spreadsheet should explain it very well.
I have no idea if there's something way simpler, but unless there is, I want a cell in the "Summary" sheet show me a sum of only those entries in "Deliveries" which have "pine" in the cell to the left AND have "Alice" in the cell two columns to the left or in the first non-empty cell above that in that column.
First obvious suggestion might be to just fill every row with a supplier name, but our actual files and the amount of types of wood are gigantic, it's a no-go. Also other sheets are based on delivery numbers, which are tied to suppliers having a single entry per delivery.
Thanks!
Make sure that every row has a name (in col C) for every type and quantity that is filled in. Then you can try QUERY() for the totals per person:
=query(Deliveries!C1:E, "select C, sum(E) where C <>'' group by C pivot D")
and another QUERY() for the totals
=query(query(Deliveries!D1:E, "select sum(E) pivot D"), "offset 1", 0)

SUMIFS function across multiple sheets

For reference, please visit this Google Doc which is a simplified example of my problem, which is to determine total sales in Blue and Green markets each month.
Each month, I receive a new sales report from accounting for all of our markets and I add the sheet to the main workbook. My team is in charge of assigning "colors" to the markets and tracking this. As it's privileged information, we can't have accounting auto-tag these in the data they send over.
One solution would be, for each new monthly report that comes in, tag each city with the color. However, we have hundreds of markets and this isn't very practical to go through each time.
I assume that a SUMIFS function would work here, but am unsure how to set it up when there are values spread across multiple sheets.
You can use this function in B8 of February tab:
=SUM(IF(COUNTIFS($A$2:$A$5,Color!$A$2:$A$5,Color!$B$2:$B$5,'Sales February'!A8)>0,$B$2:$B$5,0))
COUNTIFS($A$2:$A$5,Color!$A$2:$A$5,Color!$B$2:$B$5,'Sales February'!A8)>0 gets an array of the countries that belong to the colour specified in A8 of the current tab (Would that be possible to put only Green and remove February Sales from that cell?).
If the country belongs to the particular colour, then return the array of corresponding values in column $B$2:$B$5.
Lastly, sum this array.
Note:
You need to array enter this formula in Excel (by holding Ctrl+Shift then hit Enter after typing in the formula).
In Google Spreadsheets, you array enter a formula by wrapping the formula around =ArrayFormula(), meaning you use:
=ArrayFormula(SUM(IF(COUNTIFS($A$2:$A$5,Color!$A$2:$A$5,Color!$B$2:$B$5,'Sales February'!A8)>0,$B$2:$B$5,0)))
In Excel you can use this "array formula"
=SUM(SUMIF(A$2:A$5,IF(Color!B$2:B$5=A8,Color!A$2:A$5),B$2:B$5))
confirmed with CTRL+SHIFT+ENTER
The same formula works in google docs if wrapped in arrayformula, i.e.
=arrayformula(SUM(SUMIF(A$2:A$5,IF(Color!B$2:B$5=A8,Color!A$2:A$5),B$2:B$5)))
or you can use FILTER as user3465711 suggests, i.e.
=SUM(filter(B$2:B$5,isnumber(match(A$2:A$5,IF(Color!B$2:B$5=A8,Color!A$2:A$5),0))))

Resources