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
Related
I am using Excel to track a team game where players are divided into teams and subteams within teams. Each player within a subteam scores a certain number of points, and I would like to have a summary string for each player with the number of points other players in the same subteam scored.
Example:
A B C D
PLAYER TEAM SUBTEAM POINTS
Alice Red 1 70
Bob Red 1 20
Charlie Red 1 10
Dave Red 2 70
Erin Red 2 30
Frank Blue 1 55
Grace Blue 1 45
My desired output looks like this:
A B C D E
PLAYER TEAM SUBTEAM POINTS SUMMARY
Alice Red 1 70 Bob:20, Charlie:10
Bob Red 1 20 Alice:70, Charlie:10
Charlie Red 1 10 Alice:70, Bob:20
Dave Red 2 70 Erin:30
Erin Red 2 30 Dave:70
Frank Blue 1 55 Grace:45
Grace Blue 1 45 Frank:55
The furthest I was able to go is a combination of CONCATENATE, INDEX, and MATCH in an array formula:
{=CONCATENATE(INDEX($A$2:$A$8,MATCH(1,(C2=$C$2:$C$8)*(B2=$B$2:$B$8),0)), ":", INDEX($D$2:$D$8,MATCH(1,(C2=$C$2:$C$8)*(B2=$B$2:$B$8),0)))}
This unfortunately just outputs a summary for the first player in the subteam:
A B C D E
PLAYER TEAM SUBTEAM POINTS SUMMARY
Alice Red 1 70 Alice:70
Bob Red 1 20 Alice:70
Charlie Red 1 10 Alice:70
Dave Red 2 70 Dave:70
Erin Red 2 30 Dave:70
Frank Blue 1 55 Grace:45
Grace Blue 1 45 Grace:45
What I need to do now is:
Excluding the player for the summary (I don't want Alice in the summary for Alice, but only Bob and Charlie)
Getting it to work for multiple matches (there can be an arbitrary number of players in each subteam)
Getting CONCATENATE to work with an unknown number of strings (because as said above, there can be an arbitrary number of players in each subteam).
Ideas appreciated!
I put together a helper column that concatenates each player/points and the TEXTJOINIFS from TEXTJOIN for xl2010/xl2013 with criteria for the desired results.
Unfortunately Excel (prior to Excel 2016) cannot conveniently join text. The best you can do (if you want to avoid VBA) is to use some helper cells and split this "Summary" into separate cells.
See example below. The array formula in cell E4 is dragged to cell J10.
= IFERROR(INDEX($A$4:$D$10,MATCH(SMALL(IF(($B$4:$B$10=$B4)*($C$4:$C$10=$C4)*($A$4:$A$10<>$A4),
ROW($A$4:$A$10)),E$3),ROW($A$4:$A$10),0),MATCH(E$2,$A$1:$D$1,0)),"")
Note this is an array formula, so you must press Ctrl+Shift+Enter instead of just Enter after typing this formula.
Of course, in this example I assume 3 players. Your requirement of arbitrary amount of players cannot be met with formulas alone, but you can just extend the "Summary" section over to the right as far as necessary.
If you really wanted to, you could even concatenate the "Summary" rows to form a single cell, e.g. something like:
= CONCATENATE(E4,": ",F4,", ",...)
I am trying to use the index with match function to give me the order of people based on their rankings. My data is something like this:
A B C
1 Rank Name Score
2
3 1 Joe 100%
4 3 Bob 80%
5 1 John 100%
6 2 Dan 90%
7
8 RankOrder Name
9 1 =index(b3:b6,match(1,a3:a6,-1)) Result = Joe
10 1 =index(b3:b6,match(1&<>"b9",a3:a6,-1)) Result = John **HELP
11 2 =index(b3:b6,match(1&<>"b9&b10",a3:a6,-1)) Result = Dan **HELP
The first formula is to find who has a ranking of 1 or greater, then the second and third formula is where I'm struggling. I need to find who the has the next ranking closest to 1 but has not already been outputted in cell B9. Then the next formula would be the same but not someone that's been outputted in cell B9 & B10. Hopefully this make sense.Thanks!
Use index and aggregate with countif for aggregate's k factor.
=INDEX(B$1:B$6,AGGREGATE(15,6,ROW($3:$6)/(A$3:A$6=A9),COUNTIF(A$9:A9,A9)))
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
In SharePoint I have a table with a lookup column that takes in multiple values. I am having a problem finding a code for a calculated column that counts how many values the user chose. For example,
Favorite Ice Cream
1 Vanilla; Chocolate; Strawberry
2 Cookies and Cream; Mint
3 Coconut; Chocolate; Butter Pecan; Strawberry
And an adjacent column will be...
Number of total Ice Cream
1 3
2 2
3 4
Thank you in advance!
I'm working on Excel with a lot of data and I'm having difficulty with knowing how to sort through it to get some important numbers. I have minimal Excel experience.
Right now I'm struggling with knowing how to get the average in the difference between two columns. The trick is that I have to get the average in difference when column A is less that column B and then, the same when it's more. And all that within a category.
So for example let's say I have 3 categories: Football, Soccer, and Basketball (these are just made up ones).
So in column A, I have: Soccer, Football, Basketball. Then, in column B and C, I have the scores for John and Adam for the last 3 months, respectively. Lastly, in column D, I have the differences between their scores.
So, for example:
Category John Adam Differences
Soccer 5 3 2
Soccer 6 2 4
Soccer 3 5 2
Soccer 4 0 4
I want to create a table for within each category I have a table like below:
NÂș of cases Avg. Difference between John and Adam
When John's score is >
When John's score is <
When they are equal
Is there some type of formula where I can say something like this:
If the category is Soccer (the category being in column A), take the difference between John's score (column B) and Adam's score (column C) when John's score is larger than Adam's score, then calculate the average of those differences? Then, I would use the same formula but tweak it when John's score is smaller.
Additionally, would there be a formula where I can also, calculate within the category Soccer, how many times John's score is bigger than Adam's?
My data is much larger and I can't do this manually.
A B C D
1 Sport John Adam Differences
2 Soccer 5 3 2
3 Soccer 6 2 4
4 Soccer 3 5 -2
5 Soccer 4 0 4
6 Basketball 20 15 5
7 Basketball 7 13 -6
8 Basketball 26 10 16
9 Basketball 8 11 -3
Type in D1:
=B1-C1
Drag the formula in Column D to all rows which there are values in columns A, B and C.
Create the PivotTable.
Drag Sport to "Row Label" field. Drag Differences to "Row Label" field under Sport.
Drag Differences to "Values" field as: Count of Differences (same way the previous question)
Drag Differences to "Values" field (below Count of Differences), and set the mathematical operation as "Average" of Differences (left-mouse click Differences, choose "Values fields settings" and select "Average").
Give a right-click mouse in cell A5 (see picture bellow) and select "Group" option.
Set "Starting at" = 0; "Ending at" = 1000; "By" = 1000 (as in the picture below). Click ok.
You will have in each Sport, the count (frequency) and average Differences values for two groups:
When the Difference B1-C1 is negative; and
When the Difference B1-C1 is zero or positive.
The average of Differences when the score is equal will be always zero.