Excel syntax for getting the value in another table based on 2 cells - excel

I would like to know what is the best syntax if i want to get the price of an item depending on the specific product and its unit of measure because a product can be sold per bag or per kilo. Here's a sample content of excel sheet. The only required input for the user is the enter product name and unit of measure in the Orders Sheet.
Orders Sheet
Item Purchased | Unit | Price
-------------------+----------+---------
Product 1 | Bag | 1000
Product 1 | Kilo | 100
~~~~~~~
Price List Sheet
Item | Unit of Measure | Price
----------+---------------------+--------
Product 1 | Bag | 1000
Product 1 | Kilo | 100
Product 2 | Bag | 2000

You can use SUMIFS, which can be used specifically when the result you want is a numeric value:
=SUMIFS(C:C, A:A, E2, B:B, F2)
That's assuming though that your price list is a true price list, meaning no item is duplicated (e.g. Product 1, Bag doesn't appear more than once).

Related

Calculate Monthly Highest Selling Product - MS Excel

I am trying to figure out how to get the product with the highest sales per month using Excel. I'm new to excel and it's been a struggle understanding what formula to use.
Please help!
Use a Pivot Table to summarize the data. Use these columns in your fields:
Click the dropdown arrow in the Product column, choose value filters, Top 10. Choose top 1 by sum of sales:
Screenshot(s) refer:
Setup
Sample data (B:M) and unique product ID / unit cost list (O:Q)
Note: Unique product List ony required for Method 3 - see below
Notice col M 'Sales' derived as Store cost / unit cost:
=F4:F29/INDEX(Q4:Q10,MATCH(D4:D29,P4:P10,0))
Only relevant if transactions comprise 1 or more sales of a given product (here, transactions 1001, 1008 comprise 3 pool covers and 4 pool domes resp.). This is covered under method 3 (can also be handled by method 1, albeit only the single product/trans is given in that example).
Methods
Pivot Table method - can handle 'single' or 'multi' product variations
Countifs method - only for 'single' product per trans
Sumifs method - as for pivot table method
1. Pivot Table
(quick but not v. dynamic - i.e. requires refreshing)
a) Select the sample data, and click 'Analyse Data' in Home section of main ribbon:
b) In the 'Ask a question about your data' search bar, type 'Which is the most common 'Product' each month?
c) Select 'insert Pivot table'
Notes:
You may need to sort row labels if you want this to read chronologically Jan->Apr
You can try different variations or select one of the suggestions to allow or other summaries, e.g. by $ sales / multi-product variation etc
2. Max number of sales per month (1 sale per transaction)
requires Office 365 compatible version of Excel
Obtain unique list of months:
=UNIQUE(B4:B29)
Obtain complete & unique lists for Product IDs each month, for unique lists, determine corresponding count of product IDs (countifs); then join the filtered list corresponding to product ids with max counts using text join -
=LET(x_,TRANSPOSE(SORT(UNIQUE($D$4:$D$29))),y_,TRANSPOSE(COUNTIFS($D$4:$D$29,TRANSPOSE(x_),$B$4:$B$29,S4)),TEXTJOIN(", ",1,FILTER(x_,--ISNUMBER(MATCH(y_,IFERROR(COLUMN(y_)/0,MAX(y_)),0)))))
Option 3 - multi product/transaction
As for option 2 (Office 365, unique month, complete/unique lists, etc.) but now countifs replaced by sumifs, and col M (# sales, cf. set up) utilised:
=LET(x_,TRANSPOSE(SORT(UNIQUE($D$4:$D$29))),y_,TRANSPOSE(SUMIFS($M$4#,$D$4:$D$29,TRANSPOSE(x_),$B$4:$B$29,S4)),TEXTJOIN(", ",1,FILTER(x_,--ISNUMBER(MATCH(y_,IFERROR(COLUMN(y_)/0,MAX(y_)),0)))))
Notes:
Product codes 9822 (Jan) and 1002 (Feb) outrank other products returned by Option 2 due to multi-product sales (3 and 4 resp.).
This method is most robust as it can be used to return Product Codes with the highest profit/commission etc. (simply by altering values in col M).
E.g. setting col M = £Commission yields the following 'highest commission earning Products' each month:
In this case, Products 1002 and 1003 dominate - given their sales volumes and high unit costs (comm. assumed 20% flat across each product otherwise).
General points
Notes:
Assuming you intended to insert table as follows:
| A| B| C| D| E| F| G| H| I| J| K |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| Month | Transaction Number | Product Code | Product | Store Cost | Sale Price | Profit | Commission | First name | Last name | Sale Location |
| Jan| 1001| 9822| Pool Cover| $58.30 | $98.40 | $40.10 | 8.02| Charlie| Barns| NM |
i.e.
A
B
C
D
E
F
G
H
I
J
K
Month
Transaction Number
Product Code
Product
Store Cost
Sale Price
Profit
Commission
First name
Last name
Sale Location
Jan
1001
9822
Pool Cover
$58.30
$98.40
$40.10
8.02
Charlie
Barns
NM
☺

Combine data from multiple sheets in new excel file

I'm new to Excel so I'm sorry if this is newbie question.
I have one excel file with about 30 sheets containing sales for each day of the month for particular products. These sheets are named like "01.01.2022", "02.01.2022", "03.01.2022" and so on.
They are formatted like this
| productID | totalSold|
| --- | --- |
| 0 | 120 |
| 1 | 14 |
| 2 | 300 |
From these multiple sheets I need to add their totalSold values to an existing table that is formatted like this
productID
01.01.2022. expected
01.01.2022. sold
02.01.2022. expected
02.01.2022. sold
03.01.2022. expected
03.01.2022 sold
...
0
120
[dataFromOtherSheet]
110
dataFromOtherSheet
100
dataFromOtherSheet
1
14
[dataFromOtherSheet]
20
dataFromOtherSheet
10
dataFromOtherSheet
I already have data for "[date] expected" column.
Values in each row for "[date] sold" columns are sum of sales for that product in a given day.
I need to combine data from for example sheet called "01.01.2022" which containes all sales and place those values into column called "01.01.2022 sold". Their productID columns need to match and they are not in the same order in every sheet so I can't just use copy/paste, plus there are a lot of data so it's imposible. All tables in those sheets have same columns, only order of products is different that order in this existing table which contains expected and sold columns.
If I've understood right your problem you have to use summifs formula.
Assuming your items code are in A column and your item price are on B column you could write :
=summIfs('01.01.2022'!B:B;'01.01.2022'!A:A; A1)

How to sum values in excel only if they match a category id in a lookup

Say I have a product category lookup like so:
Sheet 1
Product Name | Product Category
--------------------------------------
product 1 | A
product 2 | A
product 3 | B
product 4 | A
product 5 | B
product 6 | C
and I also have a list of purchases which only use Product Name like this:
Sheet 2
Product Name | Purchase Quantity
---------------------------------------
product 1 | 35
product 4 | 10
product 5 | 5
I would like to produce a rollup like this:
Product Category | Purchase Quantity
------------------------------------------
A | 45
B | 5
C | 0
I've tried a variety of ways to solve this like:
SUMIF(LOOKUP('Sheet 2'!A2:A6,'Sheet 1'!A:A,'Sheet 2'!B:B), "=A", 'Sheet 2'!B2:B6)
SUMPRODUCT(LOOKUP('Sheet 2'!A2:A6, 'Sheet 1'!A:A, 'Sheet 2'!B:B)="A"*'Sheet 2'!B2:B6)
Excel doesn't like the first one. It says the formula is incorrect, but I'm not seeing why. The second one yields #VALUE. Any help on this would be much appreciated. Thanks in advance!
With A in D2, use this as an array formula.
=SUM(SUMIFS(Sheet2!B$2:B$4, Sheet2!A$2:A$4, IF(Sheet1!B$2:B$7=D2, Sheet1!A$2:A$7)))
Array formulas need to be finished with Ctrl+Shift+Enter, not just Enter.
In my opinion there is no need to use complex formulas for such an easy question. Just add another column next to Purchase Quantity sheet 2 to get the Product Category and simply use =SUMIF. I have prepare a solution to illustrate my thoughts:
Formula for VLOOKUP:
=VLOOKUP(D2,$A$2:$B$7,2,FALSE)
Formula for SUMIF:
=SUMIF($F$2:$F$4,"=" & A10,$E$2:$E$4)
Results:

How to get two+ rows to link together? Excel 2010 (Example)

I have a parts list with competitor pricing. One part number brings multiple brands up with the location of the company.
As you can see from the picture, I have part numbers for one item with three companies. I want to sort by part type. So for example I want to list only the brake pads. When I do this the blanks get sent to the bottom, but the blanks are not really blanks because they have additional info with them for that part number.
Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 | Column 7
Part No | Company A | Price | Company B | Price | Company C | Price
4656546 | Brand A | $5 | Brand A | $5 | Brand A | $5
(BLANK) | Brand b | $8 | Brand b | $8 | Brand b | $8
I have tried to use a helper column, but I have 1,000+ rows.
Does anyone know if you can link or have a relationship between two+ rows?
I hope you understand and if not. I can try to explain better.
I asume that a "blank" in PartNo means "take the PartNo from the cell above" ...
In order to normalize the PartNo (= get rid of the blanks) use another PartNo-Normalized column (e.g. [K:K]) and normalize as following:
K1 ="PartNo-Normalized"
K2:Kxx =IF(A2<>"",A2,K1)
Next convert all formulas in [K:K] into values !!! (Copy / PasteAs - Values) before sorting ... as a sort operation will destroy the calculated values.
After conversion to values it's save to sort, and you may create a filter on that column.
Depending on how well organized your data is, it might be a good idea to add one more column and fill it with 1, 2, 3, 4, 5 ... before any sorting so you can restore the original sort order just in case something nasty happens.

Counting the number of older siblings in an Excel spreadsheet

I have a longitudinal spreadsheet of adolescent growth.
ID | CollectionDate | DOB | MOTHER ID | Sex
1 | 1Aug03 | 3Apr90 | 12 | 1
1 | 4Sept04 | 3Apr90 | 12 | 1
1 | 1Sept05 | 3Apr90 | 12 | 1
2 | 1Aug03 | 21Dec91 | 12 | 0
2 | 4Sept04 | 21Dec91 | 12 | 0
2 | 1Sept05 | 21Dec91 | 12 | 0
3 | 1Aug03 | 30Jan89 | 23 | 0
3 | 4Sept04 | 30Jan89 | 23 | 0
This is a sample of how my data is formatted and some of the variables that I have. As you can see, since it is longitudinal, each individual has multiple measurements. In the actual database there are over 10 measurements per individual and over 250 individuals.
What I am wanting to do is input a value signifying the number of older brothers and older sisters each individual has. That is why I have included the Mother ID (because it represents genetic relatedness) and sex. These new variable columns would just say how many older siblings of each sex each individual has. Is there a formula that I could use to do this quickly?
=COUNTIFS($B:$B,"<>"&$B2,$H:$H,$H2,$AI:$AI,$AI2,$J:$J,"<"&$J2)
Create a column named Distinct with this formula
=1/COUNTIF([ID],[#ID])
Then you can find all the older 0-sexed siblings like this
=SUMPRODUCT(([DOB]>[#DOB])*([MOTHERID]=[#MOTHERID])*([Sex]=0)*([Distinct]))
Note that I made the data a Table and used table notation. If you're not familiar [COLUMNNAME] refers to the whole column and [#COLUMNNAME] refers to the value in that column on the current row. It's similar to saying $A:$A and A2 if you're dealing with column A.
The first formula gives you a value to count that will always result in 1 for a particular ID. So ID=1 has three lines and Distinct will result in .33333 for each line. When you add up the three lines you get 1. This is similar to a SELECT DISTINCT in Sql parlance.
The SUMPRODUCT formula sums [Distinct] for every row where the DOB is greater than the current DOB, the Mother is the same as the current Mother, and the Sex is zero.
I have a possible solution. It involves adding two columns -- One for "# older siblings" and one for "unique?". So here are all the headings I have currently:
A -- ID
B -- CollectionDate
C -- DOB
D -- MOTHER ID
E -- Sex
F -- # older siblings
G -- unique?
In G2, I added the following formula:
=IF(A2=A1,0,1)
And dragged down. As long as the data is sorted by ID, this will only display "1" once for each unique person.
In F2, I added the following formula:
=COUNTIFS(G:G,"=1",D:D,"="&D2,C:C,"<"&C2)
And dragged down. It seemed to work correctly for the sample data you provided.
The stipulations are:
You would need the two columns.
The data would need to be sorted by ID
I hope this helps.
You need a formula like this (for example, for row 2):
=COUNTIFS($A:$A,"<>"&$A2,$E:$E,$E2,$D:$D,$D2,$C:$C,"<"&$C2)
Assuming E:E is column for sex, D:D is column for mother ID and C:C is column for DOB.
Write this formula in H2 cell for example and drag it down.

Resources