how to compare values between 2 columns, if match , output corresponding column - vlookup

I Have an excel workbook that has 2 tab tab reference & Sheet 3
i want to compare Column W from sheet 3 with Column D from tab reference
If they match, it will output corresponding Colomn E value to Column AP.
Otherwise just leave blank
tab reference
Colomn D Colomn E
001 321
002 554
003 789
Sheet 3
Column W Column AP
012
002
048
001
Desired Result
Sheet 3
Column W Column AP
012
002 554
048
001 321
Any idea? Thankyou.

Use VLOOKUP and enter the following formula into the AP column, row 2 (assuming the first row is row 2):
=IFERROR(VLOOKUP(W2,'tab reference'!$D$2:$E$3,2,FALSE),"")
The range 'tab reference'!$D$2:$E$3 refers to the lookup data you showed us. This assumes you only have three rows to lookup, but you may change this formula if you have more than this.

Related

finding similar names in vlookup

i am having two columns with states, one contains like this:
Wisconsin
Washington
and other have maybe
WisconsinUSA
Washington America
so you can see that second column have a different name but its the same state.
Is it possible to check first column with second and if found some similarity just replace it with itself, so result in third column will be Washington.
Column A Column B ColumnC
Washington WashingtonUSA Washington
So the word USA is not parametar, its just something that can be in column B, not only that word.
I tried something like:
=IFERROR(INDEX(B:B, MATCH(A1, B:B, 0)), A1)
but it gaves me not every good results.
Some hints:
Columns A are some states (19) - it can be different number
Columns B are ALL STATES (50) - it can be different number, but allways this number of ALL states are greater than column A, because in A are just some of them
When i have 20th states in column B, column A is empty, but idea is that formula search in all column A and find similarity, therefore its not irrelevant if A is empty, just to check it.

PowerBI - Get the Index of the First Occurance of a value in the column

I am trying to return the Index of a first occurrence of a value in a column.
I would want to use the Calculated Column functionality in PowerBI.
For Example,
Input Output
ASD 1
ASD 1
ASD 1
GEF 4
GEF 4
HIJ 6
GEF 4
This can be done in excel using a simple formula like,
MATCH(A2,A:A,0)-1
For PowerBI to understand Index, I have created a column called as Index on the Query editor and made the data look like,
Index Input Output
1 ASD ?
2 ASD ?
3 ASD ?
4 GEF ?
5 GEF ?
6 HIJ ?
7 GEF ?
How to do this in PowerBI?
The way I did this was to find the minimal index the corresponds to the Input value in the table:
Output = MINX(
FILTER(TableName,
TableName[Input] = EARLIER(TableName[Input])),
TableName[Index])
This takes the minimal index over the table, where Input matches the value of Input in the original (earlier) row context.

How to replace specific characters of a string with tab in R

Having a data frame with a string in each row, I need to replace n'th character into tab. Moreover, there are an inconstant number of spaces before m'th character that I need to convert to tab as well.
For instance having following row:
"00001 000 0 John Smith"
I need to replace the 6th character (space) into tab and replace the spaces between John and Smith into tab as well. For all the rows the last word (Smith) starts from 75th character. So, basically I need to replace all spaces before 78th character into tab.
I need the above row as follows:
"00001<Tab>000 0 John<Tab>Smith"
Thanks for the help.
You could use gsub here.
x <- c('00001 000 0 John Smith',
'00002 000 1 Josh Black',
'00003 000 2 Jane Smith',
'00004 000 3 Jeff Smith')
x <- gsub("(?<=[0-9]{5}) |(?<!\\d) +(?=(?i:[a-z]))", "\t", x, perl=T)
Output
[1] "00001\t000 0 John\tSmith" "00002\t000 1 Josh\tBlack"
[3] "00003\t000 2 Jane\tSmith" "00004\t000 3 Jeff\tSmith"
To actually see the \t in output use cat(x)
00001 000 0 John Smith
00002 000 1 Josh Black
00003 000 2 Jane Smith
00004 000 3 Jeff Smith
Here's one solution if it always starts at 75. First some sample data
#sample data
a <- "00001 000 0 John Smith"
b <- "00001 000 0 John Smith"
Now since you know positions, i'll use substr. To extract the parts, then i'll trim the middle, then you can paste in the tabs.
#extract parts
part1<-substr(c(a,b), 1, 5)
part2<-gsub("\\s*$","",substr(c(a,b), 7, 74))
part3<-substr(c(a,b), 75, 10000L)
#add in tabs
paste(part1, part2, part3, sep="\t")

Comparing multiple columns in multiple worksheets and color if found

I am trying to compare 2 worksheets and 2 columns and then color the matches red.
For example,
Worksheet1
123 1.5
345 2.5
567 3.5
789 4.5
Worksheet2
124 1.5
367 2.5
567 3.5
891 4.5
I want to compare these worksheets and if column A in WK1 matches column A in WK2 and column B in WK1 matches column B in worksheet 2 color row red.
Don't use an IF statement to color the cel. Use conditional formatting.
As far as getting the values from another file, use the following sytax:
='[fileName.xlsx]sheetName'!C22

List all the numbers in various ranges (1 - 6; 1, 2, 5 & 23; etc)

I am working on a project where I have a column of Ward Group data, and the data is formatted as Municipality Name - Type (City, Town, Village) Wards. So for example:
ADAMS - T 1 & 2
Cumberland V 1 - 5
Marshfield - C 1 - 20, 23 - 25 & 27
....
etc.
To link this information to a government-provided ward shapefile, I need to have one line per Ward. So for example, I need to turn the above information into:
ADAMS - T 1
ADAMS - T 2
Cumberland V 1
Cumberland V 2
Cumberland V 3
Cumberland V 4
Cumberland V 5
Marshfield - C 1
....
Marshfield - C 20
Marshfield - C 23
Marshfield - C 24
Marshfield - C 25
Marshfield - C 27
Also, each Ward Group line has several columns of election data, that I want copied into each new row. So for example:
Ward Group Total Votes
ADAMS - T 1 & 2 300
needs to become:
Ward Group Total Votes
ADAMS - T 1 300
ADAMS - T 2 300
Is there a way to do this in Excel that isn't by hand, either formula or VBA?
Although not tagged as such, I suspect you are going to require code for this, so means your question "must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results." or could be deem off topic. So perhaps a start with formulae (assuming each 'row' is a single cell):
maybe regex to make the Municipality Name - Type linking more consistent (say look for letter space letter space and replace with letter space hyphen space letter space - so Cumberland V 1 - 5 ends up in a similar format to the others, ie Cumberland - V 1 - 5.)
then use =SUBSTITUTE(A1,"-",",",1) to replace the hyphens before the Type with commas (can reply on hyphens because used for range indication also).
Then "fix" the results (Paste Special Values to replace the formulae).
Then parse out the results (Text to Columns) with "," and "&" as the delimiters (only).
Insert three new columns immediately to the right of the left of these columns and parse the (existing) left column with Space and hyphen as the delimiters.
Applied to your example, at this point the results should look so:
Columns C & D are the lower and upper bounds of ranges - but I'm afraid E3 alone represents a range (though this could be split out with Text To Columns again - a point to watch out for may be confusing 27-29 with 27 & 29.
There is more could be done with formulae but I think VBA is a better bet - unless perhaps this is definitely a 'once off' requirement. For example, the votes, if in a different cell, could be attached after the pages (?) have been split out, via say a lookup function.