Excel Vlookup Function - vlookup

I have a spreadsheet that contains two worksheets. Each Worksheet contains the C column which I need to only extract the last numbers after the dash. So in Cell D it does this by using the formula:
=TRIM(RIGHT(SUBSTITUTE(C2,"-",REPT(" ",100)),100))
and the correct number is shown in Cell D as you can see.
A B C D E
250 stevem GP CONSTRUCCION-9-50399 50399 4/12/2013 0:00
223 stevem ANIMATIC MEDIA-9-50400 50400 4/12/2013 0:00
224 stevem DIGITAL ENGINEE-9-50401 50401 4/12/2013 0:00
I then need to do a vlookup on cell D in sheet 1 and match it with Cell D in sheet two which contains the same formula for extracting only the last digits after the -
My Vlookup is:
=VLOOKUP(D:D,Sheet2!A:F,2)
but I think because the lookup cell does not contain Just values, but rather a formula that returns a value, I get an error #N/A
Will Vlookup work for what I am trying to do?

(#N/A) returned by a VLookup means that the value was not found. My guess is that the issue is you are looking for values of D from Sheet 1 in column A of Sheet 2.
The VLookup function has parameters of [Lookup Value],[Table Array],[Column Index Num],[Range Lookup]
Lookup Value is the value you are searching with.
Table Array is the range of values to search in. The first column is what is searched.
Column Index Num is the column number of the table array whose value should be returned if the Lookup value is found. If there are multiple instances of the Lookup value in the table array then the function returns the first instance.
Range Lookup is true or false and determines if you only use and exact match -False, or a near match -True.
The table array you select is Sheet2!A:D and the column index number you have is 2. This means the vlookup is looking for the value in column A and if it is found will return the value in column B. If the value is not found then the vlookup returns a general error (#N/A). If needed you could capture this with the IFERROR() function wrapped around your VLOOKUP() function.
You describe you want to search for the value in column D of sheet 2 but you don't express what value you want returned. If you want just the number returned then setting the range to only one column will suffice.
Example:
=vlookup(D1,Sheets2!D:D,1,False)
This VLOOKUP() function is looking for the value D1 in the column D on Sheet 2 and if it is found it returns the number otherwise it returns (#N/A) and does an exact match search.

Related

Dax comparison do not support value type text and value type integer

i am trying to count from two columns
Column A contains category name i.e. AAT and CCAB
column B contains scores i.e 1,2,3,4 etc
i am trying to count how many people have CCAB (from column A) and score 3 from Column B.
i get an error saying "dax comparison do not support value type text and value type integer"
how can i do this, please
You can use this measure to get result.

Power BI function that checks if multiple specified values (numbers) exist in a column

Is there a function in Power BI that can check whether a list of specified values (numbers) exists in a column?
For example, in the image below, I have a column with some values and another one with 0 and 1s. You can see that some values are marked with 1 and some with 0. In order to do this, I used IF function, but this is just too cumbersome.
I am looking for a formula that can check if the values from a list like {XXXX, XXXX, XXXX, etc} exist in a column and that can easily be edited when I need to add other values.
Thank you and have a good day!
Best,
Denis
You can do that by adding a custom column for example. If we assume your table is named Table and first column is named Value, then add a custom column like this:
Where the list contains all the values of interest. This will give you a boolean column Flag:
If you want an integer column with 0 and 1 values, then change the column to something like this:
= if (List.Contains({"5006", "4905"}, [Value])) then 1 else 0

Vlookup or better alternative for retrieving column D into Column N if C contains

CONTEXT
Sheet 1, Column L has a combination of numbers and letters (internal reference) - e.g. 32948/78TPL
Sheet 2, Column C CONTAINS Column L (sheet1) - e.g. Payment proof for 32948/78TPL sent by Tom.
Sheet 2, Column D contains time/date
WHAT I WOULD LIKE TO ACHIEVE
Retrive on Sheet 1 Column N, the value of Column D where Column C (both from Sheet2) contains the value of Column L (sheet1)
Basically retrieve the time/date column from Sheet 2 for the correct row on Sheet1
WHAT I'VE TRIED
VLOOKUP("*"&$L7&"*",(Sheet12!C2:F),{3},false),"")
WHAT HAPPENS
It does return the correct value but works only for that row
If I change to VLOOKUP("*"&$L7:$L&"*",(Sheet12!C2:F),{3},false),"") it returns some strange values like "43984.76019" where the time/date cell should return values like "6/2/2020 18:14:40". So the range can't be assigned like that and probably the problem is trying to use a range with wildcards which I think it's not possible
If I manually stretch the formula (1st version) it returns wrong values for rows where Column L is empty
Is VLOOKUP the way to go?
Can someone please point me to a better direction?
Thanks in advance.
try:
=ARRAYFORMULA(IFNA(VLOOKUP(L2:L, {REGEXEXTRACT(Sheet2!C2:C,
TEXTJOIN("|", 1, L2:L)), Sheet2!D2:D}, 2, 0)))

Can't count cells populated by a RegExMatch function

I am attempting to count the sum of a column populated by a RegExMatch function but using a COUNT function, eg =COUNT(F2:F100).
The function that populates a cell with '1' is:
=IF(RegExMatch($E2,"SKU123"),"1","")
I can see '1' appear many times in the column but when I attempt to sum the column I get a zero answer.
Any suggestions for how I perform a better RegExMatch (or alternative) or way to sum the column?
Change your formula from
=IF(RegExMatch($E2,"SKU123"),"1","")
to
=IF(RegExMatch($E2,"SKU123"),1,"")
and will work.
COUNT returns the number of numeric values in a dataset, and you were filling with strings. SO in your version it will always return 0.

vlookup to find match and return another element in row

i have two sheets. first column of both sheets has userids, but there is only some overlap of ids between the two sheets. i want to keep the userids in the first sheet, but in the second sheet, the second column has a point of data that i want. for those userids in the first sheet that are also in the second sheet, i want to get this data.
so, for say the first row's userid in the first sheet, how could i use vlookup to find that same userid in the second sheet (if it exists), get the value of the second column of that match, and bring it back to the second column of the first sheet?
thanks
Modify and put this formula into the first cell of the second column on the first worksheet. Then copy and paste it down the column:
=VLOOKUP(A1, Sheet2!A$1:B$100, 2, FALSE)
Let's look at the parameters for this function:
A1: This value, on this worksheet, is what we're searching for in the range given in the next parameter. When you copy and paste the entire formula down the column, it increments the row # with each row. In row 2, it will be modified to A2, and so on.
Sheet2!A$1:B$100 : This is the range that we are interested in, on the second worksheet. It is the top left to bottom right cell. The $ symbol tells Excel not to change the row #'s when you copy and paste the formula down the column. Modify B$100 to fit the range of data you are interested in... something like B$30 if you only have 30 rows of id's on the 2nd sheet.
2: This is the column you are interested in retrieving the value, relative to the above parameter. In this case, the 2 corresponds with column B.
False: This instructs Excel to find the exact match.