How to automate moving words in excel in the same column - excel

I'm not good with excel, my knowledge is very limited, but I'm stuck with a project where I have 3,077 rows. There are a few columns where I need to move around a few words or numbers. All I need right now is to know how to do it in one column, or if it's even possible. I have a list of addresses and 90% of them have been entered incorrectly. Rather than go through each one one by one I'm hoping there's something I can run to swap the word or number around. If need be I can create a new column.
Below is an example. The first two are correct, the next four are not. I need the second number to be after ROAD or after HWY. i.e. 6 ROAD 3066 or 1059 HWY 516. Thank you for your help in advance.
42 ROAD 3050
68 ROAD 3400
6 3066 ROAD
1059 516 HWY
986 516 HWY
33 3403 ROAD

If I understand correctly, your task is as follows:
your have three columns
one of them is not a number
you want to have them in order number/text/number
Your input cells are A1/B1/C1. Then create the following additional columns:
D1 = IF(ISNUMBER(A1);A1;B1)
E1 = IF(ISNUMBER(A1);IF(ISNUMBER(C1);B1;C1);A1)
F1 = IF(ISNUMBER(C1);C1;B1)
Those are then the desired output columns.

Related

How to sum each value of a column for different individuals in excel?

I have a little problem with a dataset.
My data look like this:
Volume Pressure
Patient 1 31 15
34 35
32 44
Patient 2 34 23
23 23
23 24
I want to obtain a final output of a mean patient that has for each value of pressure and of volume the mean of the pressures/volumes of the two patients.
Volume Pressure
Mean Patient (31+34)/2 (15+23)/2
(34+23)/2 (35+23)/2
(32+23)/2 (44+24)/2
I have no idea how to write this rule, as I don't know how to explicit that I want to repeat this procedure for every patient I have (I have more than two).
Thank you very much in advance!
I think you are making it too difficult. Simply use AVERAGE and drag.
For example, =AVERAGE(B7,B2)
IF you are open to a helper column you can use the following solution.
For the helper column you want to ad a test/sample ID. To keep it simple I used a numbering system starting at 1 and increments by 1 for each successive test. Plae the following formula in a column adjacent to your first patient results and copy down. You can hide this column later for presentation purposes or stick it off to the side if so desired
=IF(AND(A3="",B3=""),"",IF(AND(A3<>"",B3<>""),1,E2+1))
Then lets build a table of results. Column 1 will be your test/sample ID. Column 2 will be your mean volume, and column 3 will be your mean pressure. In the first cell of column 2 place the following formula:
=SUMIF($E:$E,$G3,B:B)/COUNTIF($E:$E,$G3)
Copy this formula down as needed and one column to the right.
Update cell references to suit your needs.
Dont use full column reference if you have other information in the column either above or below your data range.

How to resolve Excel IF AND question query formula

Need help with a Excel formula.
I have two sets of data in two tables, with the same number of columns and rows.
One table has data for male, the other one for female.
Each table has a common definer (age). All the other data are different. All data are in numbers. Some are negative.
I aim to use a single cell to get a result coefficient used by a specific equation, and I need to channel the input data by two criteria. One is gender, the other one is age. I am trying the IF AND formula, but it is not working.
Here is an example.
age (D2) coefficient (D2-D4)
Table Female.
18-30 yrs 25
30-60 yrs 35
60-70 yrs 41
So here is the data to process:
D1 F
D2 29
D3 115
(MEANING Gender - female; age 29; weight 115 pounds)
I was trying the IF AND formula
=IF(AND(D1="F";D2>17;D2<30);(D3+H2);IF(AND(D2>=30;D2<60);(D3+H4)))
Now, this works fine when I only calculate the female data, but I can't seem the find the way to include the formula to choose from the MALE table, if the subject is male ("M").
Any help or clues on how to resolve this?
Welcome to stackoverflow. It would be easy to help you if you paste a screenshot of your table etc as it would make us understand your problem clearly.
Anyway, two solution advice from me:
1- you can use nested if operators but not like yours. Before expressing conditions with and operator, add another if to start processing data related to females. Like this: =IF(D1="F";IF(AND(D2>17;D2<30);(D3+H2);IF(AND(D2>=30;D2<60);(D3+H4))).
After processing females, add the same formula strings this time for males. This will solve your puzzle I guess.
2- my second advice would be creating a user-defined function. I often create a user-defined function if my formula gets too long and become hard to read. I strongly recommend you to search for this as it will make you better-understand the logics in excel functions and make you equipped against your puzzles in future.

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

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))

Determining Total Frequency of a Numeric ID with Several ID and Frequency Columns

I apologize for the confusing title, I've added an example to clarify. I believe this is actually pretty easy, but I just can't for the life of me determine how to do it. Essentially I have long lists of IDs and their corresponding frequencies, around 45 lists all very long. I want to determine the total frequency of each ID, but the issue is that each ID is not in each list. I tried importing the data into access, but the operation was too complicated and resulted in errors in access.
I would be able to do this in SPSS if there were a discrete number of IDs for If statements, but in total there are around 10,000 IDs necessitating a way to do this quickly.
The data looks like this, with 50 ID Code Columns with an associated frequency column.
ID CODE Frequency ID CODE Frequency
0001 3 0002 3
0002 4 0003 4
0003 2
Expected output
ID CODE Frequency ID CODE Frequency Final ID Code Total Frequency
0001 3 0002 3 0001 3
0002 4 0003 4 0002 7
0003 2 0003 6
I think that this is possible with vlookup, but I'm not really sure how to go about this.
I apologize for the rudimentary question, look forward to any comments and will provide any answers and clarifications.
Calculating the total frequencies would be easy in SPSS. After reading the file into SPSS, run the following syntax:
(this assumes variable names will have changed automatically this way: IDCODE Frequency IDCODE_A Frequency_A IDCODE_B Frequency_B etc')
varstocases /make FinalID from IDCODE IDCODE_A IDCODE_B
/make fr from Frequency Frequency_A Frequency_B.
dataset name orig.
dataset declare summary.
aggregate /outfile=summary /break=FinalID /TotalFreq=sum(fr).
The original data will now be organized in long format, which is easier to analyse. The summarized frequencies will appear in a new dataset called "summary".
If you have many more data columns in your file, putting all the variable names in the syntax can be a hassle. You can shorten the process by sorting the variables by name in the variable view window and copying them from there.
But if you're going to repeat the process and might have a different number of variables in each run, you should automate the process completely. You can do it like this:
spssinc select variables macroname="!ID" /properties pattern = "IDCODE*".
spssinc select variables macroname="!FRQ" /properties pattern = "Frequency*".
These commands automatically define variable lists which you can now use like this:
varstocases /make FinalID from !ID
/make fr from !FRQ.
Try using the SUMIFS function. Here is what I have in cell F2:
`=SUMIFS($B$2:$B$4,$A$2:$A$4,E2) + SUMIFS($D$2:$D$4,$C$2:$C$4,E2)`
I then copied it down to the cells below. The E2 became E3 in the 2nd data row and then E4 was in the 3rd data row.
Hopefully this example will give you an idea of how it works. You'll probably have to do some adjusting to account for more rows, and if you don't have the same columns A-F like I do.

Excel - Is it possible to create nested 2D stacked bar chart?

I'm trying to create a "nested" 2D stacked bar chart in excel but I only got until stacking the columns. Unable to show "work %" inside "Used %". Is there a way to accomplish this in excel? I seen a similar example but that was in BI and not in excel.
Update:
Please note that "Work" is a subset of "Used".
Total =100 & Used = 50, then Used % = 50%
Used = 50 & Work = 50 , then Work % = 50% (of Used).
Hope this clarifies.
Name Type Total Used Work Used % Work %
Mike Sport1 100 50 25 50 50.00
Mike Sport2 175 75 50 42.86 66.67
Mike Sport3 50 40 10 80 25.00
Mike Sport4 200 110 40 55 36.36
Rita Sport1 75 25 10 33.33 40.00
Rita Sport2 150 100 80 66.67 80.00
Rita Sport3 100 75 35 75 46.67
Rita Sport4 125 100 80 80 80.00
I'm suggesting an approach further down, but your question needs a lot of clarification. The clarification would normally go into a series of me writing comments and you responding by editing your question and providing more details.
I don't feel like going through this rigmarole right now, so, please read my questions for clarification, try to understand what I'm after and then go and edit your question to provide the required detail.
My questions to you:
What is the information you want to derive from the data? What question are you posing to the data that the chart should answer?
Your data table does not make sense. The "total" column totals --what exacty--? How come "used" is 50 and "work" is 25 but Used% is 50 and Work% is also 50?
Name Type Total Used Work Used % Work %
Mike Sport1 100 50 25 50 50.00
Please edit your question and either amend the data or explain how it all hangs together.
What data do you want to chart? The scribbles on your scan are less than conclusive.
My suggestion:
These questions aside, you can create a stacked column chart with the data you want to display. You may need to create a helper table as the data source for the chart, just so everything is in the correct place for easy selection and rendering.
Whether or not something is a percentage or part of a bigger unit can be shown by formatting the colors of the data points, and with data labels.
You can add data labels to any series and then edit the labels to receive their values from spreadsheet cells. The whole thing can be automated with VBA.
If you don't want to write that kind of VBA yourself (which is understandable) you can download the free XY Chart Labeler tool by Rob Bovey here. It is ill-named and can actually add labels to any chart type.
I'm aware that this is not a complete answer. I expect you to edit your question with the missing information, so I can subsequently edit my answer to supply a real answer.

Resources