A B C
1 Fruit Color Meat <- Column Header
2 Banana Red Pork
3 Apple Black Chicken
4 Orange White Beef
From the table1 above to table2 below:
A B
1 Name What? <- Column Header
2 Banana Fruit <- Formula should return these values, based on table 1
3 Red Color
4 Beef Meat
5 Pork Meat
Looking for a formula to return corresponding column name in B2,3,4...
I tried =INDEX(Table1[#Headers],MATCH(J:J,Table1,0))
It would seem that the three columns are unique; e.g. there would never be a Beef in the Color column. In that case you can simply query each column, passing back a 1, 2 or 3 as the case may be.
=IFERROR(INDEX(Table1[#Headers],
ISNUMBER(MATCH([#Name], Table1[Fruit], 0))*1+
ISNUMBER(MATCH([#Name], Table1[Color], 0))*2+
ISNUMBER(MATCH([#Name], Table1[Meat], 0))*3),
"no column")
I'm not sure whether Port was an intentional misspelling but it does demonstrate what occurs when there is no match.
Related
I have a dataset with two columns column1 = radius and column2 = fruit
radius = 10,2,3,0,10,2,0,12,6,10
fruits = apple,apple,mango,watermelon, watermelon, apple, mango, watermelon, mango, apple
I want to write a function that find the values with zero and replace it with the mean value of that fruit class using pandas/python. For example If the apple has 0 value in radius column. That zero has to be replaced with mean value of apple values not considering watermelon and mango values.
I tried df.mean() but I want for individual class name.
I am working on an excel sheet that will help me with meal-planning. Currently, I have my data stored in a manner like demonstrated below:
**Monday**
Breakfast Bagel 1 Cream Cheese 1
Lunch Spinach 1 Eggs 4 Cream Cheese 1
Dinner Pork 1 Eggs 2
**Tuesday**
Breakfast Cereal 2 Milk 1 Eggs 3
Lunch Bagel 1 Butter 1
Dinner Eggs 2
CURRENT OUTPUT:
Ingredients Needed:
Eggs 2
Bagel 2
Spinach 1
Pork 1
Cereal 2
Milk 0
Butter 0
Cream Cheese 0
Where the numbers represent the number of servings of each ingredient I need to buy.
The problem I am facing is that my current formula:
=INDEX($C$12:$C$58, SMALL(IF(ISNUMBER(SEARCH($B$60, $B$12:$B$58)), MATCH(ROW($B$12:$B$58), ROW($B$12:$B$58))), ROW(B1)))
Only indexes one row at a time. For example, if I am searching for how many Eggs I need to buy for the week, the formula would return 2 eggs (because it is only searching column B for Eggs and returning column C).
Is there a work-around that would allow me to be able to return the full number of ingredients I need to buy? I realize I could index each column individually, however, since I have many ingredients (100+), using my current formula doesn't seem feasible.
Any help is massively appreciated
You can use SUMIF, where the sum range is offset from the criteria range. For example, for simplicity, let's say that C12 to H19 contains the data (ingredient and quantity), try...
=SUMIF($C$12:$G$19,B60,$D$12:$H$19)
...where B60 contains the ingredient of interest. Notice that the sum range D12:H19 is offset from the criteria range C12:G19.
When I use FIRST(CG1) in 'Cell Values' the grand total is not summing up instead its showing one of the values from the result of FIRST(CG1).
Please advise if we have to always use sum(XXX) to get the grand total summed up.
Short answer, yes if you want the Grand Total to be a summation of your data. Applying a grand total to a different aggregation will have different results.
AVG will average the averages of your Category Axis
MAX will take the MAX of the Max for each category
Cumulative Sum will take the "Last" value in your Category since it doesn't have any additional values to SUM up.
Product will take the Product of Products
First and Last you are already aware of.
Long Answer:
You actually CAN sum the first value of a column from a column grouping.
For example, consider the following data set.
[Grouping] [Food] [Color] [Weight]
Fruit Apple Yellow 4
Fruit Apple Green 2
Fruit Apple Red 4
Fruit Banana Yellow 5
Fruit Banana Brown 2
Fruit Orange Orange 3
Vegetable Carrot Orange 4
If, in your custom expression, you put
Sum(if(RankReal([Grouping], "ties.method=first", [Food]) = 1, [Weight], 0))
it will find the first instance of each food in your data set, so regardless of how you group the left, your results, subtotals, and grand totals will sum only the first instance of each food.
So you will be able to see the following:
Fruit Apple 4
Banana 5
Orange 3
Subtotal: 12
Vegetable Carrot 4
Subtotal: 4
Grand Total: 16
I'm trying to sum a column that is from an input table to link to a reference table that a user can select inputs to create a "group." I think an example is better here:
Inputs
Key Type Name Count lookup_value
1 Fruit Apple 3 1 - Apple
2 Fruit Orange 5 2 - Orange
3 Fruit Pear 6 3 - Pear
4 Veggie Broccoli 3 4 - Broccoli
5 Veggie Celery 2 5 - Celery
The user puts these inputs in, and from another screen is able to customize a group (each of the selection is from a dropdown,lets call each array of data input_column name such as input_lookup_value for our formulas). Using the following formula in a cell next to "Total Pieces of Food,"
=sumproduct(--(A1:A3=input_lookup_value),input_count)
We will get the correct answer of 14, as below.
Group Name: Food Sally Likes
Total Pieces of Food 14
Item
A1 1 - Apple
A2 2 - Orange
A3 3 - Pear
However, if the user is to put in just Celery in cell A1, the formula will not work, and the "Total Pieces of Food" will return 0, since the order does not match the Input table order. Is there another formula or way I can attack this that will return the correct count, and still allow the user to enter the list in any order?
To put what #Jeeped (with his permission) suggested in the comments into an official answer:
The formula is:
=SUM(SUMIFS(Sheet16!D2:D6, Sheet16!E2:E6, A4:A6))
This is an Array Formula, So confirm with Ctrl-Shift-Enter
I have 2 tables here. On first table, I would like to flag 'Partial Validated' (column A) to "Done" when the 2nd table (column F) flagged to YES for the find_item.
The 'Find Item' column can be any substring of column B. How to achieve this?
1st Table
COLUMN A COLUMN B
Partial validated List
================== =================================
<Done> Apple, Orange, Banana, watermelon
Apple, watermelon
<Done> Mango
Banana, Tomato
<Done> Orange, Apple
2nd Table
COLUMN E COLUMN F
find_item validated
=========== =========
Orange YES
watermelon NO
Mango YES
Apple NO
Appreciate your advice.
First of all, for the best performance you have to use macros. Formulas aone cant handle those operations in that sceme.
Ifyou cannot use macros, you'll have to pivot 2. table to this:
note: replace ; with , in formulas as it depends on your regional settings
ORANGE Watermelon Mango APPLE
YES NO YES NO
and separate comma data in 1st table to this
Column B column C column D Column E
Apple(Cell B2) Orange Banana Watermelon
Apple Watermelon
Mango
Banana Tomato
Orange APPLE
then count the YES & occurences of given item from table 1
ORANGE(Cell G1) Watermelon Mango APPLE
YES NO YES NO
1(x) 0 0 0
0 0 0 0
0 0 1 0
0 0 0 0
1 0 0 0
code of cell marked with (x) :
=IFERROR(IF(HLOOKUP(G$1;$B3:$E3;1;FALSE)>0;IF(G$2="YES";1;0);0);0)
then finally put this down to cell A2 and drag down
=IF(SUM(G3:J3)>0;"DONE";"")
this will create the desired action, whenever yo change the value YES of a given item to some other value, the total unit count will change and if unit total in a given row is equal to 0 "done" will change to zero