Trying to come up with a formula for a spreadsheet I am working on, but hit a road block.
I need to use an INDEX and MATCH formula to ensure that the cell is going to lookup a sheet full of data and find all matches based on an ID number. I then need to work out the % value of how often that column was populated with data for that ID number.
Essentially as an example:
The data table would look like:
ID | Notes Added
1 | Yes
7 | Yes
12 | Yes
6 | Yes
10 |
12 |
And the result would be:
ID | Populated %
12 | 50 %
As you can see, the values that it should return would be 50%, as there are 2 entries that are listed for the ID of 12 (this is where the MATCH and INDEX would come in), however in the Notes Added, only 1 of the entries has a value.
The data table that it draws from will either have a value, or have no value, calculating the % would be based on if there is/isn't a value.
You'll want to use COUNTIFS Function. It would look something like this:
=COUNTIFS(B4:B9,C16,C4:C9,"Yes") / COUNTIF(B4:B9,C16)
=COUNTIFS(<ID Values Range>,<Id Value>,<notes added range>,"Yes") / COUNTIF(<ID Values Range>,<Id Value>)
Then just set the cell formatting to %.
Related
I want to populate this formulae but this level of nested loop are not allowed...
=IF(D2<101,"27.50",IF(D2<151,"21.34",IF(D2<201,"26.07",IF(D2<251,"29.81",IF(D2<301,"34.54",IF(D2<351,"39.27",IF(D2<401,"44.00",IF(D2<451,"49.72",IF(D2<501,"56.87",IF(D2<551,"61.60",IF(D2<601,"66.33",IF(D2<651,"71.06",IF(D2<701,"75.90",IF(D2<751,"80.63",IF(D2<801,"85.36",IF(D2<851,"87.67",IF(D2<901,"90.97",IF(D2<951,"92.40","97.90"))))))))))))))))))
where D2 is calculated like =(A2+B2)/2
You can use INDEX(MATCH()) to solve your issue, but the order of lookup array must be descending, and your limits should be +1 as it works in greater than or equal to form, so if this is the lookup table:
A B
252 29.81
202 26.07
152 21.34
102 27.5
This will be the formula:
=INDEX($B$1:$B$4,MATCH(D2,$A$1:$A$4,-1))
The best way to go about this is to use a lookup table as a half-way point, either somewhere on the sheet or in hidden cells/sheet if preferred.
The table will look something like this:
|-----|-------|
| 101 | 27.5 |
|-----|-------|
| 151 | 21.34 |
|-----|-------|
| 201 | 26.07 |
|-----|-------|
etc...
Then you can use a lookup to find the value based on the condition, let's say this table is in Sheet2!A1:B3:
=IFERROR(INDEX(Sheet2!$B$1:$B$3,SMALL(IF($D$2<Sheet2!$A$1:$A$3,ROW(Sheet2!$A$1:$A$3)-ROW(Sheet2!$A$1)+1),1)),"97.90") - Entered as an array formula (Ctrl+Shift+Enter)
INDEX(Sheet2!$B$1:$B$3, - Create a 1 based index (index starting from 1) of B1:B3
IF($D$2<Sheet2!$A$1:$A$3,ROW(Sheet2!$A$1:$A$3)-ROW(Sheet2!$A$1)+1 - Returns a reference to the position of the all items in A1:A3 that are larger than D2 as an array (by taking the row number minus the row number of the first row plus 1)
SMALL([If()],1) - Return the first, smallest row number from the array that INDEX() then looks for
IFERROR([Index(Small(If()))],"97.90") - As any number greater than the largest number in the table will produce an error, then return "97.90" instead
I have an excel spreadsheet with a list of values, column A contains the grading, column B contains the number of occurrences:
A | B
---------------
Grading | Count
1 | 1
2 | 1
3 | 2
4 | 3
5 | 5
I would like to find the average grading based on the count but to do this I need to build a list based on these values, I.E. the above chart should translate into:
=AVERAGE(1,2,3,3,4,4,4,5,5,5,5,5).
I have managed to come to a solution through a very convoluted method of creating a new table, using IF and COUNTIF to print out an array and then AVERAGE the entire range but this is time consuming to repeat and I'm sure there is much simpler way of doing this.
If I'm not mistaken, you can just take the sum of product of columns A and B, then divide by the sum of the Count column:
=SUMPRODUCT(A2:A6, B2:B6) / SUM(B2:B6)
Note that using your hand written expanded formula yielded the same results:
=AVERAGE(1,2,3,3,4,4,4,5,5,5,5,5)
I've got a table with columns, each containing customer contact information. I've also got a formula that finds a phone number using multiple criteria: customer ID, type (mobile, home etc), and primary Y/N. The problem is this information can occur several times but with a different date, in which case the newest occurrence needs to be selected. The current CSE formula is:
=INDEX($C$6:$BZ$18;10;MATCH(<client_ID>;IF(($C$8:$BZ$8=<client_ID>)*($C$17:$BZ$17="home")*($C$18:$BZ$18="Y");$C$8:$BZ$8);0))
where
$C$6:$BZ$18 contains all data
$C$8:$BZ$8 contains all client IDs
$C$17:$BZ$17 contains the types of phone numbers
$C$18:$BZ$18 contains whether this number is the primary number of that type
$C$8:$BZ$8 contains the date a number was entered
The data looks like this:
B C D
---------------------------------------------------------------------
8 CLIENTID |Client1 |Client1 |
9 other | | |
10 other | | |
11 other | | |
12 other | | |
13 other | | |
14 other | | |
15 PHONE NUMBER |9876543210 |1234567890 |
16 DATE |2015-04-15 |2015-04-16 |
17 TYPE |Home |Home |
18 Primary |Y |Y |
The above formula selects phone number 9876543210 but it needs to select 1234567890 because that is the latest entry.
Any ideas on how to proceed from here?
The underlying value of dates are numbers so we can look for the furthest date to the right in a row by searching for an impossibly high number with the MATCH function without looking for an exact match.
The array formula in F6 is,
=INDEX($B$8:$BZ$18, MATCH(F$5, $B$8:$B$18, 0), MATCH(1E+99, IF($B$8:$BZ$8=$C6, IF($B$17:$BZ$17=$D6, IF($B$18:$BZ$18=$E6, $B$16:$BZ$16)))))
Array formulas need to be finalized with Ctrl+Shift+Enter↵.
If your dates are in ascending order (left-to-right) then an exact match will have to be sought. A three criteria pseudo-MAXIF formula can return that into the original formula modified to look for an exact match. If the maximum date is duplicated, the first one is returned.
=INDEX($C$8:$BZ$18, MATCH(F$5, $B$8:$B$18, 0), MATCH(MAX(INDEX($C$16:$BZ$16*($C$8:$BZ$8=$C6)*($C$17:$BZ$17=$D6)*($C$18:$BZ$18=$E6), , )), IF($C$8:$BZ$8=$C6, IF($C$17:$BZ$17=$D6, IF($C$18:$BZ$18=$E6, $C$16:$BZ$16))), 0))
In order to provide some maths without errors, I've shifted the calculation ranges to C:BZ. Array formulas still need to be finalized with Ctrl+Shift+Enter↵.
By appropriately locking either the row, column or both of the cell addresses, we can use the column header to identify a different category from column B as I have done with DATA LINE. The formula can be simply filled right.
I am using the SMALL formula in H2 to find the lowest price in the row, which works great.
=IF(ISERROR(SMALL(A2:F2,COUNTIF(A2:F2,0)+1)),"",SMALL(A2:F2,COUNTIF(A2:F2,0)+1))
I am having trouble retrieving the value to the left of it (its corresponding item#) with OFFSET.
A | B | C | D | E | F | G | H
item# | price | item# | price | item# | price | lowest value item# | lowest value
123 | 70 | 456 | 80 | 789 | 67.89 | ? | 67.89
Also,I do not know which column will have the lowest value, A-F can change.
I've spent several hours searching and tried using the original formula as the Reference part for the OFFSET:
=OFFSET(IF(ISERROR(SMALL(A2:F2,COUNTIF(A2:F2,0)+1)),"",SMALL(A2:F2,COUNTIF(A2:F2,0)+1)),0,-1,1,1) and variations of it. This returns #Value!
Am I on the right track? Is OFFSET the correct way to do this? Thanks
I would also remove the dependency on H2 by replacing it thus, simply adding a MIN function
=INDEX(A2:F2;MATCH(MIN(A2:F2);A2:F2;0)-1)
however, you always need to distinguish between item number and price. Sometimes the item value could be lower than price and then your formula wouldn't work. It would return the item value as the lowest value and then will return the price for the preceding item. It would be a mess.
So to resolve this, you need to add two MATCH conditions to look for the exact match:
here is the formula the LOWEST VALUE ITEM#:
=INDEX(A2:F2;(MATCH(MIN(IF(A1:F1="Price";A2:F2));A2:F2;0)-1)*(MATCH("Item#";A1:F1;0)))
and the formula to find the LOEWST VALUE PRICE
=MIN(IF(A1:F1="Price";A2:F2))
For example in the following:
Value in C2 is the lowest, however it is not the lowest price value, which is itself in F2 That is why you need to add these match conditions to find the value above which is item# or above which is Price.
So for Price I used MIN(IF and for Item# i used a MATCH condition.
here is the excel sheet example downloadable from dropbox
P.S. do NOT forget to adjust the formuals to your regional settings, by replacing the ";" with ","
tell me if it works.
Is OFFSET the correct way to do this? - No
OFFSET expects as its first parameter a range reference, not a value.
If your prices are unique, use this (if they are not, I'm not sure what result you would expect)
=INDEX(A2:F2,MATCH(H2,A2:F2,0)-1)
That said, your SMALL formula looks suspect. It looks like you want to return "" if all the prices are 0. But your formula will return the smallest item# in that case. Can you confirm or explain?
I have two columns of data in Excel, one containing dates and the other values 1 or 2 which represent a specific status (like an enum).
Here is an example data set:
2014/07/04 | 1
2014/07/04 | 1
2014/07/04 | 2
2014/07/04 | 1
2014/07/05 | 2
2014/07/06 | 1
2014/07/06 | 1
2014/07/06 | 2
I need to get a graph of the percentages of the number 1 over days; in the above example
July 4th: 75%
July 5th: 100%
July 6th: 66%.
I've tried pivot tables and charts with no luck because I can't write my own function for values (COUNTIF for ones divided by COUNT), only use the predefined ones which aren't of any use.
Does anyone know how I would go about doing this?
You could do this with a pivot chart.
I made up my own data so it doesn't quite match but it is the same idea.
For the pivot table fields I used
Legend Fields:Compare
Axis Fields:Date
Values: Count of compare
For values under Value field settings goto show value as and change this to % of column total and summarize value by Count.
If you only want to see number one just put a filter on the column labels.