If blank return 0 else run vlookup - arrays

I would like to use the vlookup function to match two criteria values firstly based on the value selected in a dropdown menu (country) and the value in A2(name). If the value in A2 Sheet matches the one of the values in the A column in Sheet2 and the value of the dropdown menu in Sheet1 matches one of the values in Sheet2 Column D (Which is a concatenation of the name and country) I would like to return the corresponding value in Sheet2 ColumnC.
If the value is 0 or blank I would like to return 0.
This is what I have tried
=ARRAYFORMULA(
IF(
ISBLANK(
IFERROR(VLOOKUP(A2&C2,Sheet2!$A$2:$E$61,3,1),"0"))))
Not sure what I might be doing wrong
Here is a sample of my data
Sheet 1:
A B C
name1 (vlookup) [dropdownmenu]
and Sheet 2
A B C
name1 val concatenationofA&B
Here is a test sheet as requested:
https://docs.google.com/spreadsheets/d/1jsFnaGY7N9nXyPs5vR32jG5G838w1SgB2XIad7bEFXg/edit?usp=sharing

try:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A&C2:C, {Sheet2!A2:A&Sheet2!B2:B, Sheet2!C2:C}, 2, 0), 0))

I managed to resolve this using the query function
=QUERY(Sheet2!$A$2:$E$61,"select C where B = """&C12&""" and A = """&A12&""" ")
The only problem is I don't know how to suppress NA values/replace them with the value 0

Related

Spreadsheet Formula read the wrong Value

I run the Vlookup Formula with data like this in he Spreadsheet:
A65 B65 C65 D65 E65 F65 G65
AGR 1 1 Penjualan 12/12/2022 Makanan 15,500
I used formula :
=IFNA(Vlookup(A65,A:D,4,0),"")
should returns the value as "Penjualan" or "" if nothing.
but it returns other value.
your formula is correct unless there is one more AGR in range A1:A64. try:
=IFNA(VLOOKUP(A65, A65:D65, 4, 0))
to see that its working properly

ISBLANK(...) = FALSE even thought the cell is blank in google sheet

Hi everyone,
I have 2 tables, 3rd column for Table 1 is Value 1 and 3rd column for Table 2 is Value 2. I combined these 2 tables by expanding both tables first so that all the columns are aligned as shown in the screenshot above (Column E to Column H).
The formula in all the yellow cells are:
Cell E4 : =QUERY(A4:C10,"Select A,B,C,' ' label ' ' 'Value 2' ")
Cell E12 : =QUERY(A12:C20,"Select A,B,' ',C label ' ' 'Value 1' ")
Cell K7 : =QUERY({E5:H10;E13:H17},"Select * where Col1 is not null",0)
Cell P7 : =ArrayFormula(IF(ISBLANK(M7:M12),100,M7:M12))
In column P, I want to return 100 as Value 1 if the cells in Column M is blank. So by right I should get 2,34,55,100,100,100 in column P but right now the formula still return 3 blank cells.
I suspect that is because the QUERY function that I used before which make the cell is not blank although it seems like still a blank cell. May I know is there any trick that I can use to find the blank cells in column M and column N (preferably don't touch the QUERY formula) since ISBLANK() is not working in this case?
Any help or advise will be greatly appreciated!
Edited
makes sense. you cant use ISBLANK because cell is not blank. remember that QUERY inserted an empty space.
try:
=ARRAYFORMULA(IF(ISBLANK(TRIM(M7:M12)), 100, M7:M12))
ISBLANK is so sensitive that it will detect even residue from TRIM
update:
=ARRAYFORMULA(IF(TRIM(M7:M12)="", 100, M7:M12))

color first five rows of a table in SSRS

Iam developing a report where I need to provide special effects on 1st few columns. How can I color code or provide 3D effect for first five rows of a table in SSRS? Also, count of values in these columns?
For example:
My date count
A 3
B 4
C 1
D 1
E 5
F 6
G 7
Now, I should color rows start from A to E and get total count of that ( e.g. 14 in this case)
How can I I acheive this?
While Strawberryshrub's answer would probably work just fine, there's an easier way that can get you the same result. You should be able to use the SSRS function RowNumber to indicate which rows should be colored. Try the following expression in the background color property for that row.
=IIF(RowNumber(Nothing) < 6, "Green", "No Color")
Also, for the count that you need, you should be able to use a similar pattern.
=SUM(IIF(RowNumber(Nothing) < 6, Fields!count.Value, 0))
One possible option is to cathegorize your first column with an calculated field:
'Name: CustomCathegory
=IIF(Fields!MyDae.Value = "A" Or
Fields!MyDae.Value = "B" Or
Fields!MyDae.Value = "C" Or
Fields!MyDae.Value = "D" Or
Fields!MyDae.Value = "E", "Cathegory1", "CathegoryElse")
Now you can use the row coloring (font or background) and use the following expression:
=IIF(Fields!CustomCathegory = "Cathegory1", "Blue", "Black")
You can also sum by CustomCathegory (textbox outside the detail section)
=Sum(IIF(Fields!CustomCathegory = "Cathegory1", Fields!Count.Value, 0))
or group your table by CustomCathegory and add header or footer with the sum per CustomCathegory

Counting rows in a table based on multiple array criterias

I am trying to count rows in a table based on multiple criteria in different columns of that table. The criteria are not directly in the formula though; they are arrays which I would like to refer to (and not list them in the formula directly).
Range table example:
Group Status
a 1
b 4
b 6
c 4
a 6
d 5
d 4
a 2
b 2
d 3
b 2
c 1
c 2
c 1
a 4
b 3
Criteria/arrays example:
group
a
b
status
1
2
3
I am able to do this if i only have one array search through a range (1 column) in that table:
{=SUM(COUNTIFS(data[Group],group[group]))}
Returns "9" as expected (=sum of rows in the group column of the data table which match any values in group[group])
But if I add a second different range and a different array I get an incorrect result:
{=SUM(COUNTIFS(data[Group],group[group], data[Status],status[status]))}
Returns "3" but should return "5" (=sum of rows which have 1, 2 or 3 in the status column and a or b in the group column)
I searched and googled for various ideas related to using sumproduct or defining arrays within the formula instead of classifying the whole formula as an array but I was not able to get expected results via those means.
Thank you for your help.
Because your group and status criteria are a different number of values (2 values for group, but 3 values for status), I'm not sure you can do this in a single formula. Best way I know of to do this would be to use a helper column (which can be hidden if preferred).
Put this array formula in a helper column and copy down the length of your data (array formulas must be confirmed with Ctrl+Shift+Enter):
=AND(OR(data[#Group]=group[group]),OR(data[#Status]=status[status]))
And then get the count with: =COUNTIF(helpercolumn,TRUE)
You could use a slightly different approach, using Power Query / Power Pivot.
Name your tables Data, Group and Status, then create the following query, named Filtered Data:
let
tbData = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
tbGroup = Excel.CurrentWorkbook(){[Name="Group"]}[Content],
tbStatus = Excel.CurrentWorkbook(){[Name="Status"]}[Content],
#"Merged Group" = Table.NestedJoin(tbData,{"Group"},tbGroup,{"Group"},"tbGroup",JoinKind.Inner),
#"Merged Status" = Table.NestedJoin(#"Merged Group",{"Status"},tbStatus,{"Status"},"Merged Status",JoinKind.Inner),
#"Removed Columns" = Table.RemoveColumns(#"Merged Status",{"tbGroup", "Merged Status"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Status", type number}})
in
#"Changed Type"
Load To as connection only, and tick Load to Data Model
Now create a DAX measure:
Status Sum:=SUM ( 'Filtered Data'[Status] )
You can then use the following formula on your worksheet, to get the Sum of Status values, for rows matching the criteria specified in the Group and Status tables:
=CUBEVALUE("ThisWorkbookDataModel","[Measures].[Status Sum]")
Simply refresh the data connection to update the value.

EXCEL lookup an a row / array based on a cell value

I would like to look up a row (an array) based on the DATE value, such that an array of price value (instead of a single return if using VLOOKUP) is returned for a given DATE value. Below is the data
Column A Column B Column C Column D
Row1 DATE Product A Product B Product C
Row2 1/1/2017 1 5 7
Row3 7/1/2017 3 6 5
Row4 13/1/2017 2 8 3
Thank you in advance
So one way to do this would be to make the lookup row a relative value. So assuming that your sample data is on Sheet1 and the list of dates you are looking up against is on Sheet2 Col A with a header. I would first make the lookup range a named range so that Sheet1 Col A thru Col D is named something like "Data". Then in B2 place the below formula and copy it to over to Col D and then all the way down the list of dates.
=vlookup($A2,Data,Column(B1),False)
The $ for A2 allows it to always look at column A even when copying over the formula. The Column(B1) returns a value of 2 but when you copy that formula to the left it will change to Column(c1), Column(d1)... thus changing what column of data you want returned.

Resources