Combining multiple values attached to the same variable in Excel - excel

I need to add multiple values related to the same variable into one single entry. Here is what my worksheet looks like:
ColA ColB ColC
Onion Ounces 12
Onion Ounces 6
Carrot Kilo 3
Basil Grams 25
Carrot Kilo 6
Basil Cups 3
Here is what I am trying to figure out how to do:
ColA ColB ColC
Onion Ounces 12
Onion Ounces 6
Carrot Kilo 3
Basil Grams 25
Carrot Kilo 6
Basil Cups 3
__________________
Onion Ounces 18
Carrot Kilo 9
Basil Grams 25
Basil Cups 3
*If colA matches (both entries are 'Basil'), but colB doesn't match (one entry is 'ounces' and one is 'cups') it needs to have separate entries.
I'm very new to excel and not even sure how to phrase this question correctly, so my apologies if this has been answered many times before!
Thank you so much for your help!

Use Query:
=QUERY(A1:C6,"Select A,B,Sum(C) group by A,B")

Related

On SQL with one-to-many merging and many as a narrowing condition

Use sqlalchemy
Parent table
id name
1 sea bass
2 Tanaka
3 Mike
4 Louis
5 Jack
Child table
id user_id pname number
1 1 Apples 2
2 1 Banana 1
3 1 Grapes 3
4 2 Apples 2
5 2 Banana 2
6 2 Grapes 1
7 3 Strawberry 5
8 3 Banana 3
9 3 Grapes 1
I want to sort by parent id with apples and number of bananas, but when I search for "parent id with apples", the search is filtered and the bananas disappear. I have searched for a way to achieve this, but have not been able to find it.
Thank you in advance for your help.
Translated with www.DeepL.com/Translator (free version)

VBA Excel - Sort a daily delivery manifest into groups based on complex rules

I am trying to come up with a way to sort my Excel-Table. I wrote a very basic VBA to do this when it was a random sort only. Now there's complex parameters/rules I have to meet and it's way outside my skillset.
The problem: I receive a daily file with a list of items via shipments like the example below. The list can have as few as 1 and as many as 24 items. I have to sort these by restaurant.
Example Original List
ITEM SHIPMENT
Oranges 1
Apples 1
Grapes 1
Pears 2
Pork 3
Chicken 4
Rice 5
Peas 5
Beans 5
Water 5
Corn 5
Milk 5
Eggs 5
Salmon 6
Tofu 7
Juice 8
Cheese 8
Salt 8
Pepper 9
Onions 10
Oats 11
Barley 11
Kale 11
Chips 12
The items need to be sorted out to 6 restaurants and there are complex rules:
Overall Rules
No Restaurant can have more than 1 item from a shipment
No Restaurant can have more than 4 items
Sorting Rules
Restaurant 1 always gets the first two items (Items 1-2)
Restaurant 2-5 evenly gets the next 16 items (Items 3-18)
Restaurant 6 gets the next 2 items (Items 19-20)
Restaurant 1 and 6 then evenly get the last 4 items (Items 21-24)
If there are more than 6 items in a shipment (more items than restaurants) the extra items stay in the warehouse.
The Overall Rules override the sorting rules. For example in our example list Restaurant 1 cannot have both Oranges and Apples since they are from the same shipment so the sort changes.
Example Sort
Restaurant 1 Shipment
Oranges 1
Pears 2
Rice 5
Kale 11
Restaurant 2
Apples 1
Peas 5
Salmon 6
Salt 8
Restaurant 3
Grapes 1
Beans 5
Tofu 7
Pepper 9
Restaurant 4
Pork 3
Water 5
Juice 8
Onions 10
Restaurant 5
Chicken 4
Corn 5
Cheese 8
Oats 11
Restaurant 6
Milk 5
Barley 11
Chips 12
Warehouse Items
Eggs 5
Looking at it as a whole now I'm not even sure this is possible and I have no idea how to go about doing it. If anyone has any input I'd love to hear it. Thank you so much for your help.

Excel match/index by column pair?

I am definitely a beginner when it comes to advanced Excel syntax. I tried searching for an answer to my question, but I may be too inexperienced to know how to look. Also possible I misspecified my title. Apologies if this has been answered previously.
Say I have the following 3 columns
A B C
1 Alabama Alabama Red
2 Alaska Wyoming Blue
3 Arizona Alaska Yellow
4 Arkansas Florida Green
5 California Arkansas Black
And I want to produce a list of same-row B/C pairs that have B values equal to A values:
D E
1 Alabama Red
2 Alaska Yellow
3 Arkansas Black
How can I do this?
Thank you thank you thank!

Returning the last item in a subset with excel formula

In this example I would like to mark any customer that has bought a pen most recently(or bottom of the list). I have my data sorted by CustomerID and ServiceDate with the most recent as the last. I would like to be able to mark all of the customer’s transactions only if the last purchase was a pen (333).
I have been trying formulas with COUNTA but, not sure how to do it when relying on a subset of data.
=INDEX(C:C,COUNTA(C:C))
This will give me the last value in a column.
Customer ID Custmer Name Item Number Item Name Date Desired Results
1 Bob 222 Paper 1/1/2016 X
1 Bob 111 Tape 1/1/2017 X
1 Bob 333 Pen 1/1/2018 X
4 Greg 333 Pen 1/1/2015
4 Greg 111 Tape 1/1/2016
6 Chris 111 Tape 1/1/2015 X
6 Chris 333 Pen 1/1/2018 X
8 Luke 333 Pen 1/1/2013
8 Luke 333 Pen 1/1/2014
8 Luke 222 Paper 1/1/2015
8 Luke 111 Tape 1/1/2016
8 Luke 111 Tape 1/1/2018
9 Tom 333 Pen 1/1/2013 X
You can do this by creating an additional column. The additional column will find all customers whose last purchase was a pen using this formula: =IF(AND(C2=333,B2<>B3),B2,"").
The next column will give you your desired output: =IF(OR(B2=$F$4,B2=$F$8,B2=$F$14),"X","").
Thanks to joe I was able to figure this one out.
I still had to make another column.
I put this in column F.
=IF(AND(C2=333,B2<>B3),1,"")
Then in column G.
=IF(AND(COUNTIFS(A:A,A2,F:F,1)=1),"Yes","")
This worked great.

Excel Finding What Place a Value Comes In

I am trying to find a way to get which place a certain value comes in in a range of other values. Or another way to look at it is I want to turn the SMALL function inside out. The SMALL function looks like this, "=SMALL(array, k)" where it looks for the k place in an array. I need the find what the k is. I hope that makes sense, but if not here is one more example.
A B C D
1 Kate 12.25 =PLACE($B$1:$B$13,B1) 4
2 Cindy 15.80 =PLACE($B$1:$B$13,B2) 10
3 Mark 11.85 =PLACE($B$1:$B$13,B3) 3
4 Thomas 12.98 =PLACE($B$1:$B$13,B4) 5
5 George 13.58 =PLACE($B$1:$B$13,B5) 7
6 Kim 14.52 =PLACE($B$1:$B$13,B6) 9
7 Tim 11.54 =PLACE($B$1:$B$13,B7) 2
8 Frank 12.99 =PLACE($B$1:$B$13,B8) 6
9 Fran 17.85 =PLACE($B$1:$B$13,B9) 11
10 Caroline 14.25 =PLACE($B$1:$B$13,B10) 8
11 Alex 19.20 =PLACE($B$1:$B$13,B11) 12
12 Lilly 25.20 =PLACE($B$1:$B$13,B12) 13
13 Peter 11.22 =PLACE($B$1:$B$13,B13) 1
Also I can easily do it with VBA, but I do not want to. I want to do it in cell and I do not want to have to sort them first.
RANK function does this, i.e. in your case this formula in row 1 copied down
=RANK(B1,B$1:B$13,1)
The 1 at the end indicates the order of ranking (ascending here). Leave that out and you get descending ranking

Resources