Excel Formatting: Tracking Distance (if statements, random number, sum) - excel

Hey there Stackoverflow users!
So I'm trying to track mileage for the distance of drives to different addresses in different cities. I made an example table of what I'm trying to accomplish. Let's say we started with 100 km and drove to somewhere in CITY2 which let's say takes between 8-25 km (there and back) so we get "KM" 10. This gets added to our start and we get 110. Now the next "start" is 110 and we drive to CITY1 which is 26-45 km for example. Let's say that was 30, which gets added to the "Start" and you get "End" which goes down. And so on and so on.
Now, I could do the basic C2 =B2+D2 and B3 =C2, but I'm not 100% sure how to check if a cell contains a certain text (in this case, "CITY#"). And if it does contain a certain CITY#, then I need to have "KM" produce a random number between a range of numbers to then get added to "Start" to result in "End."
Also here are the ranges
CITY1 (26-45),
CITY2 (8-25),
CITY3 (45-60),
CITY4 (0). The E column was just a test for search.
Any help would be appreciated!
*EDIT: So I have =IF(ISNUMBER(SEARCH("CITY2",A2)),RANDBETWEEN(26,45)) but is there a more efficient way to check the other CITY# or do I just make one long SEARCH thing?

This should at least get you started, with the caveat that all your addresses must end in "comma-space-CityName", and there are no other instances of "comma-space".
Use RIGHT and FIND to extract the city name, and then VLOOKUP the name against a table with city name and range boundaries. Finally generate and random number between the range using RANDBETWEEN.
Formula in D2:
=RANDBETWEEN(VLOOKUP(RIGHT(A2,LEN(A2)-FIND(", ", A2)-1),$F$1:$H$5,2,0),VLOOKUP(RIGHT(A2,LEN(A2)-FIND(", ", A2)-1),$F$1:$H$5,3,0))

Related

Excel formula to find a number within a range of numbers and return a date

First time writing one of these, so I will try and explain what I'm trying to do in an understandable manner.
I'm trying to create a spreadsheet to track when a premium bond wins, and have it return the date that the winning premium bond was purchased. Because premium bonds cannot be purchased singularly, when you buy them your bond numbers are given to you a range (eg: 111AA111111- 111AA111210).
As this is the data they provide, I've set my spreadsheet up with purchase date in column A, first number of the range in column B, and last number of the range in column C.
Sample image of the sheet with example bond ranges and purchase date:
Now on a separate sheet I've listed the wins, with win date in A, winning bond number in B, and prize amount in C. In D or E I would like to somehow get it to then give me from the first sheet the date of purchase that winning bond was from.
Sample image of the sheet with winning bond numbers and month they won:
I've done a lot of googling and found similar threads to do this, but none of them have been quite what I want and I've not yet been able to work out how to tweak them into doing it. These have used index and sumproduct, but I'm yet to get it to work.
Any help in the right direction is greatly appreciated. If this doesn't make sense let me know and I'll try and explain it better.
So, like this:
INDEX($B$3:$B$5,MATCH(C9,$C$3:$C$5,1))
Not added a constraint to limit to the upper value, but you could.
This answer is pretty much the same than #SolarMike's answer but based on a diferent point of view.
If the pattern is always like 111AA111111 where 1 is a numeric value and AA is a text value and unique then you can extract the text part from each id using function MID and search for it with INDEX and MATCH:
Formula is:
=INDEX($A$1:$A$3;MATCH("*"&MID(B9;4;2)&"*";$B$1:$B$3;0))
But for this to work each AA must be unique.

Why is the result of this "countifs" formula = 0?

My goal is determine how many times a given teammate is matched up with another given teammate over 3 rounds of golf played by 3 different teams. The same roster of 12 players is changed up each round. The goal is to minimize the number of times the players are paired up with the same people over the 3 rounds.
I attempted to use the COUNTIFS formula in excel, but it returns 0 when checking if the name of each player is in the same "Team" range.
In my sheet, i have a table for players to show how many times they are paired up with different people in the 3 rounds. I can't even get it to calculate the matchup from Team 3 in Round 1 (Mike & Matt paired up), let alone move on to summing up the entire set of data.
From the screenshot you can see my equation =COUNTIFS(Q3:Q6,S3,Q3:Q6,T1) in cell T3, referencing the data in Q3:Q6 for the names Mike and Matt.
I've reviewed plenty of examples using COUNTIFS from other types of information/data types, so I don't understand why my formula fails. When I replace one of the cell references to a name with a wild card * then it returns a result of 1. If I take out one of the two references all together it returns a result of 1, for the player name that remains.
=COUNTIFS(Q3:Q6,S3,Q3:Q6,T1)
Q3:Q6 is the table I'm referencing at the moment. The same table is referenced for both players. S3 is Mike and T1 is Matt. Both players are listed in the reference range, so it seems to me that the condition is satisfied for both components.
I don't get any error messages, just a result of 0 when I'm expecting 1.
Because COuNTIFS() is AND not OR So the cell would need to be both Matt and Mike at the same time, which is not possible.
To do OR we need to do something slightly different:
=SUMPRODUCT(COUNTIFS(Q3:Q6,CHOOSE({1,2},S3,T1))
This will return 2 if both are in the range so to get it to 1 we do:
=--(SUMPRODUCT(COUNTIFS(Q3:Q6,CHOOSE({1,2},S3,T1))=2)
Which will now return 1 if both are found in the range and 0 if only one or none are found.
So we can string 9 of these together to get the output you want:
=(SUMPRODUCT(COUNTIF($M$3:$M$6,CHOOSE({1,2},T$1,$S2)))=2)
+(SUMPRODUCT(COUNTIF($O$3:$O$6,CHOOSE({1,2},T$1,$S2)))=2)
+(SUMPRODUCT(COUNTIF($Q$3:$Q$6,CHOOSE({1,2},T$1,$S2)))=2)
+(SUMPRODUCT(COUNTIF($M$10:$M$13,CHOOSE({1,2},T$1,$S2)))=2)
+(SUMPRODUCT(COUNTIF($O$10:$O$13,CHOOSE({1,2},T$1,$S2)))=2)
+(SUMPRODUCT(COUNTIF($Q$10:$Q$13,CHOOSE({1,2},T$1,$S2)))=2)
+(SUMPRODUCT(COUNTIF($M$17:$M$20,CHOOSE({1,2},T$1,$S2)))=2)
+(SUMPRODUCT(COUNTIF($O$17:$O$20,CHOOSE({1,2},T$1,$S2)))=2)
+(SUMPRODUCT(COUNTIF($Q$17:$Q$20,CHOOSE({1,2},T$1,$S2)))=2)
It will now count how many times the pairs were on the same team:

Lookup Value based on multiple criteria

Good day everyone - I am trying to create a grade sheet for my swimming classes at school. It needs to be based on a few criteria - 1. boys/girls, 2. What stroke, 3. Time swum
I have a column for Time swum and a column with a dropdown of boys freestyle, girls freestyle etc to choose from. Then a criteria table where you get 30 point for swim x time less for each stroke for boys and girls. I was trying to use index match - but that will only return one of the strokes. As seen in the image - I need Column X to return the Points from column AB based on Column T dropdown selection, based on the range of the table with all the stroke times.
I've gotten this far : =index(AB2:AB6,MATCH(S2,AG2:AG6,1)), but that assumes all are swimming backstroke and all are girls.
I am hoping I am explaining this effectively enough.
Thanks in advance for the help.
You can use OFFSET to move the column you are matchin to the right. Also my understanding is that is for example in column "Freestyle Girls" someone reaches time 50 she should be put into line 55 - Grade A, 25 Points. If so you will need to do this:
1) reverse order of your data lines - if you want to use MATCH with last parameter "-1" (returns lowest value greater or equal to lookup value) for time (when you reach 50, you are worse then 40 so you will go to line with 55) you will need to have the values in descending order so the grades will go D to A* instead of A* to D.
2) use formula
=IFERROR(INDEX(AB:AB,MATCH(S2,OFFSET(AB:AB,0,MATCH(T2,AC1:AF1,0)),-1)),AB2)
Basically what it does is this:
OFFSET(AB:AB,0,MATCH(T2,AC1:AF1,0))
this moves the search column for the final MATCH to match the style you select
INDEX(AB:AB,MATCH(S2,OFFSET(...),-1))
this is standard search like you tried, only the OFFSET is inside so it looks in correct column.
As there is no value above Grade D it would cause error if somone nearly drowned and took 100 to finish so you need IFERROR to make sure it correct that.
Note: this assumes that value in T matches the values in the column names AC-AH. It your example the word order seems flipped. Also I put into my formula only 4 different styles so you will need to change the part stating AC1:AF1 to contain all the styles

AverageIf and Multiple data strings

I'm involved with a youth football tournament on the referee side, with assessing/coaching the referees. I've just taken over doing the data entry for the referees assessment scores which we then use to determine who gets finals etc and am looking to extract more usable information from the data to help us identify trends.
I've got (up to) 200 referees, each receiving from none to two assessment scores each day for 5 days. The scores are entered as both the raw mark and the weighted mark based on match difficulty (along with a host of other data about the match that isn't relevant to this issue.
I can extract the average mark (raw and weighted) across all referees without issues and have done so using the below formula, which is the raw average mark:
=AVERAGE(Working!AK4:AK200,Working!BK4:BK200,Working!CL4:CL200,Working!DL4:DL200,Working!EM4:EM200,Working!FM4:FM200,Working!GN4:GN200,Working!HN4:HN200,Working!IO4:IO200,Working!JO4:JO200)
But I also want to extract the average mark (raw and weighted) across two subsets - Academy and non academy referees, to help plot trends and determine where resources need to be utilised.
I've attempted to use an AVERAGEIF formula, but am getting a #VALUE! return. This is the formula that I've attempted to use to return the average raw mark for those referees in the academy:
=AVERAGEIF(Working!G4:G200,Working!G4:G200="Yes",(Working!AK4:AK200,Working!BK4:BK200,Working!CL4:CL200,Working!DL4:DL200,Working!EM4:EM200,Working!FM4:FM200,Working!GN4:GN200,Working!HN4:HN200,Working!IO4:IO200,Working!JO4:JO200))
If I do the same formula as above, but without the brackets around the [average_range], I get a 'you've used too many arguments, and it highlights BK200.
From what I've been able to find so far online, it seems that the formula I'm trying to use would only work if ALL the cells in (Working!G4:G200) returned "Yes". However if there are only 50 academy referees as indicated by "Yes" in G column, then I want those specific scores to be averaged, and the inverse for the non-academy referees.
I thought about having another sheet, which would simply contain populate from Column G (a simple =G4 and then populated down to =G200 next to all of the scores), consolidated into a block of raw marks columned under Assessment 1, 2, 3, 4.... and then the same for all of the weighted marks which would populate from the equivalent cell on the working sheet, but there's a lot of filtering, and re-sorting that goes on on the working sheet, and I'm not 100% certain that that wouldn't cause issues.
Any feedback on how to work through this problem, so that I can display the overall average mark for academy and non-academy referees in both raw and weighted form would be much appreciated, and I apologize if this post is rather convoluted.
I don't think there is a neat solution if the scores are in several columns which are not consecutive.
My suggestion is:-
(1) Work out the sum for each column separately and total them up
(2) Work out the count for each column separately and total them up
(3) Divide Sum by Count to get Average.
In my small example below with 3 referees and 3 columns:-
(1) In K2:-
=SUMIF(H2:H4,"Yes",B2:B4)+SUMIF(H2:H4,"Yes",D2:D4)+SUMIF(H2:H4,"Yes",F2:F4)
(2) In K3:-
=COUNTIFS(B2:B4,">=0",H2:H4,"Yes")+COUNTIFS(D2:D4,">=0",H2:H4,"Yes")+COUNTIFS(F2:F4,">=0",H2:H4,"Yes")
(3) In K4:
=K2/K3
This would include any zero scores (if this is possible) but exclude any blanks.
You can then scale it up to your data.
Beyond this, you would have to change the data structure either
(1) Add a row to label the columns that you want to average e.g.
Score 1 Score 2 Score 3
3 0 3
so you could pick up only the columns labelled 3 say
Here's how it would be in my small example:-
In K3:-
=SUM((B$2:F$2=3)*($H3:$H5="Yes")*B3:F5)
Which is an array formula and must be entered with Ctrl-Shift-Enter
In K4:-
=SUM((B$2:F$2=3)*($H3:$H5="Yes")*(B3:F5<>""))
another array formula
In K5:-
=K3/K4
This is how the columns you want are labelled with a 3 in row 2, so it ignores the other columns:-
(2) Consolidate them into another sheet as you suggest.

Excel - Rank value based on range (X is the Yth highest value)

I'm wondering if someone could tell me if the following is possible, and if it is, how one would go about achieving it please.
I am working on a event points table. For example think of a race, if a person finishes first they get 100 points, 2nd 99 points etc. There are 2 championships, an open championship which includes everyones and a members championship for a select number of people.
I have a completed open championship table which contains a column for the names of people who are racing, and a column for the number of points they achieved in that event.
In a seperate sheet I have a similar formatted table but with a column of 'members' names. What I would like to do is pull through the points from the open standings sheet but then recalculate the points rewarded to give the highest ranked member 100 points, 2nd 99 etc.
So for example if member John Doe scored 76 points in the open championship but was the highest ranked member in that event, they would receive 100 points in the members championship.
The only way I can think I could go about this is to pull the numbers through from the open champ sheet to the members champ sheet using vlookup, then rank the numbers based on a range, so '97' from '100, 97, 65' is the 2nd highest value, then take that value (-1) from 100. So 100-(2-1)=99 points
Any help would be much appreciated.
Something like this copied down might suit:
=CHOOSE(RANK(B1,B:B),100,99,98,97,96,95,94,93,92)
with the values extended as necessary, assuming columnB has the members' points from the open standing (and the names may be in ColumnA).

Resources