I am attempting to create a dashboard - for which one of the tabs will aim to filter a list of people based on multiple criteria. For the "front cover" part of this i thought representing the criteria through checkboxes would be helpful, but have not had any inspiration on how i could make this pull in from a raw data tab with different formulas. An example of how i envisage this would look is here (example cover and raw data):
https://docs.google.com/spreadsheets/d/1RzQ5vJYwpqDClqcPe_U7meRdtFBYL_Gn6b8_yKIP1RU/edit#gid=0
The main issue i'm having is that it covers multiple criteria and i'm struggling to come up with a formula to return data with that. So, in the example sheet, i could check "apples" and "mushrooms" and it would return the peoples names from the raw data tab who satisfy this criteria.
I have used google sheets formula and the query function within sheets but am mainly finding it difficult to see how this would be possible.
If anybody had a solution to this, or a similar way they think would achieve the same goal, any help would be much appreciated!
Thanks,
Sam
I've updated your spreadsheet, with the formula in Data!F2
=IFERROR(FILTER(A2:D9,
IF(Front!$C2 = TRUE, SEARCH(Front!$B2, $B$2:$B$9), LEN($A$2:$A$9)),
IF(Front!$C3 = TRUE, SEARCH(Front!$B3, $B$2:$B$9), LEN($A$2:$A$9)),
IF(Front!$C4 = TRUE, SEARCH(Front!$B4, $B$2:$B$9), LEN($A$2:$A$9)),
IF(Front!$C6 = TRUE, SEARCH(Front!$B6, $C$2:$C$9), LEN($A$2:$A$9)),
IF(Front!$C7 = TRUE, SEARCH(Front!$B7, $C$2:$C$9), LEN($A$2:$A$9)),
IF(Front!$C8 = TRUE, SEARCH(Front!$B8, $C$2:$C$9), LEN($A$2:$A$9)),
IF(Front!$C10 = TRUE, SEARCH(Front!$B10, $D$2:$D$9), LEN($A$2:$A$9)),
IF(Front!$C11 = TRUE, SEARCH(Front!$B11, $D$2:$D$9), LEN($A$2:$A$9))), "No Values Returned in filter. Please try again.")
This should do what you're looking for.
Update
I've been asked to show how this function works.
To start with the IFERROR this is wrapped around the main function, so if the FILTER returns nothing, the user is not met with an error message.
The bulk of the function is built around FILTER which acts as a proxy for QUERY, which is what #Sam Breddy originally tried.
Working with the checkboxes that evaluate to TRUE or FALSE depending on if they have been checked or not, we can started to create our dynamic filtering function.
The first filter parameter ... IF(Front!$C2 = TRUE, SEARCH(Front!$B2, $B$2:$B$9), LEN($A$2:$A$9) ... determines if there are any Apples in $B$2:$B$9 only if the checkbox in Front!$C2 is set to TRUE.
The trick here is to have a valid value for when the checkbox is FALSE. If the FALSE parameter was set to nothing / blank, an error would pop up:
FILTER has mismatched range sizes. Expected row count: 8. column count: 1. Actual row count: 1, column count: 1.
To counter this, I'm just returning the first column's length back to the function with LEN($A$2:$A$9) which will have no effect on the filter.
The interesting part is the SEARCH which returns:
The position at which a string is first found within text and ignores capitalization of letters. Returns #VALUE! if the string is not found.
Search finds the String you're looking for ... in this case Apple and then passes that string's location back to the FILTER allowing it to only show the rows where it evaluates to to TRUE.
E.g. SEARCH(Front!$B2, $B$2:$B$9) will return 1
By using a SEARCH method for each subsequent parameter for our FILTER function, they act as an OR allowing the function to evaluate for APPLES or ORANGES.
Honestly, I took a stab at this problem, and ended up coming out on top. I don't think it will work for items in the same column that have the same first letter
E.g. If you're looking for Apples and Andy's in the same column ...
I'm also sure there might be some issues with doing this sort of dynamic filtering over two columns with the same values, but this solution should fit your needs.
Cheers,
Related
i've the following formula the problem i've is, this isn't working as it should be.
=SUMIFS(E9:14,$I$16:$I,FALSE(),$H$16:$H,G8)
E9:E14 is the part which should be summed up when the checkbox in I16:I = FALSE and if the name matches in H16:H from G8. My problem is I am getting this error
The array arguments of "SUMIFS" vary in size
My question would be, how do I get this exact formula to work? Exactly these areas have to be covered and cannot be changed, otherwise everything else is broken.
EDIT: Added example spreadsheet
https://docs.google.com/spreadsheets/d/1DdTSZAfGTpoeun3k2qqkDMG1jnaUaSz6wgSf2heIIDI/edit?usp=sharing
You need to adjust your ranges. Here's how =SUMIFS() works and then you'll see why you need to adjust the function.
=SUMIFS() looks for ranges and then applies the logic. So when you are telling the function to summarise E9:E14 it interprets it as:
SUM(E9,E10,E11,E12,E13,E14)
provided the following conditions. The conditions will tell the function whether to include each of the components (i.e. E9,...,E14).
Whether a condition is met or not is decided using a simple boolean (true/false) array. This could for example be I9:I14=FALSE which is interpreted as the array
{IF(I9=FALSE),IF(I10=FALSE),...,IF(I14=FALSE)}
resulting in an array similar to this:
{TRUE,TRUE,FALSE,FALSE,FALSE,TRUE}
(assuming the conditions I9, I10 and I14 are met but not the other three. The same is done for the second condition (the values in column H being equal to the value in G8, resulting in another array similar to this:
{TRUE,FALSE,FALSE,TRUE,FALSE,TRUE}
(assuming that only the values in H9, H12 and H14 are equal to G8.
When the function compares the two condition arrays and returns an aggregate array similar to this:
{TRUE,FALSE,FALSE,FALSE,FALSE,TRUE}
because only for the first and the last value the conditions are met. Therefore the =SUM function becomes like this:
SUM(E9,FALSE,FALSE,FALSE,FALSE,E14)
where FALSE = 0 so it returns
=SUM(E9,E14)
Here's where you get into trouble
You try to pass the function conditional arrays that are of a different size to the sum array (E9:E14), in effect asking it to compare apples and the age of your neighbour. What you need to do is to create the calculation you have in column E in a new column in rows 24 down and use that as the sum range in =SUMIFS().
So basically i want to check if certain range of field is not blank or has a certain value
so
=ArrayFormula(COUNTIF(NOT(ISBLANK(H24:I28)), true))
will count if they are blank
How can i edit it to also search for a certain value so far i've tried :
=ArrayFormula(COUNTIF(NOT(ISBLANK(H24:I28)) OR(IFERROR(SEARCH("someValue",H24:I28,1)>0,FALSE)), true))
Here is a link to a sheet as an example:
https://docs.google.com/spreadsheets/d/1sc8xmLf8_EYFoQb3kNQRdxdd-9PemrJ4lDhTfIqCJNg/edit?usp=sharing
Update following OP's details:
Well i want to count every value except anything that starts with the word Empty basically
=COUNTIF(H24:I29,"<>") -
COUNTIF(ArrayFormula(REGEXMATCH(H24:I29,"Empty")),TRUE)
Functions used:
REGEXMATCH
ArrayFormula
COUNTIF
Initial answer
To find whether theValue exists or not, you can use the following formula:
=IF(COUNTIF(H24:I28,"<>")>0,IF(COUNTIF(H24:I28,"someValue")>0,"someValue","no value"),"empty")
To count how many times theValue exists, please use:
=IF(COUNTIF(H24:I28,"<>")>0,IF(COUNTIF(H24:I28,"someValue")>0,COUNTIF(H24:I28,"someValue"),"no value"),"empty")
(Of course you can adjust the "messages" to your liking)
Functions used:
COUNTIF
IF
You could use the OR() operator:
Example:
=ArrayFormula(OR(COUNTIF(NOT(ISBLANK(H24:I28)),true),IFERROR(SEARCH("someValue",H24:I28,1)>0,FALSE)))
References:
- OR() function
Google Sheets tells me that there is a formula parse error for the following and I can't seem to find my mistake.
I have little programming experience but I want to make a fairly simple invoice form for the business I work in. I've written the following formula in a line total:
=IF(B28="Rabais", if(REGEXMATCH(I28,%),((sum(J19:J27)*I28)*-1), (I28*-1)), if(H28=0, I28, (H28*I28)))
I need that line total to change according to the following rules:
If the value "Rabais" is selected in the dropdown in cell B28, and if cell I28 contains a percentage, then the formula returns the negative of that percentage of the sum of the values of cells J19 to J27.
If the first criteria is true and the value of I28 isn't a percentage, then the formula returns the negative of the value of I28.
If the first criteria is false, then the formula checks if H28 is empty, and if so it returns the value of I28
If both If statements return false, then the formula returns the value of H28 times the value of I28.
I thought I had written everything properly, but obviously, I made a mistake somewhere and I can't seem to find it so I would appreciate a fresh set of eyes pointing it out.
this is how you do it:
=IF(B28="Rabais",
IF(REGEXMATCH(TO_TEXT(I28), "%"), (SUM(J19:J27)*I28)*-1, I28*-1),
IF(H28=0, I28, H28*I28))
I'm wanting to sum a column from a certain point to another certain point which is dictated by the user and a drop-down box. Awkward to explain, I think best to view spreadsheet.
Something along the lines of this is my thought process:
SUM(
VLOOKUP(CURRENT LEVEL CELL,
VLOOKUP(DROP DOWN BOX VALUE,NAMED RANGE 'RARITY',COLUMN 2,FALSE) , COLUMN 2, FALSE)
:VLOOKUP(DESIREDLEVEL CELL,
VLOOKUP(DROP DOWN BOX VALUE,NAMED RANGE 'RARITY',COLUMN2,FALSE) , COLUMN 2, FALSE)
)
Which would be:
=SUM(VLOOKUP(F11,VLOOKUP(F10,rarity,2,FALSE),2,FALSE):VLOOKUP(F12,VLOOKUP(F10,rarity,2,FALSE),2,FALSE))
However, that just gives me errors:
VLOOKUP evaluates to an out-of-bounds range
so I can't even see if it would be summing all the values between those two points or just those two points themselves.
Essentially I'm trying to get the first VLOOKUP's range, to be a VLOOKUP of the drop-down box. Assuming we can get that working somehow, I then want it to sum the values from the first VLOOKUP's end cell, to the VLOOKUP after the : found cell.
Is there a way to have the result of a VLOOKUP set as the named range?
Ie, vlookup2 returns "rare", vlookup1 uses vlookup2's result as the named range;
=vlookup1(A1, vlookup2 result, column, false)
TL:DR
=vlookup(X, one of multiple named ranges dictated by what is in the drop down box, 2, false)
UNTESTED
Please try in F13:
=sum(offset(index(indirect(Vlookup(F10,Rarity,2,0)),,2),F11,,F12+1-F11))
and in F14:
=sum(offset(index(indirect(Vlookup(F10,Rarity,2,0)),,2),F11,1,F12+1-F11))
I suspect there is scope for simplification but your well organised Sheets is set up in a different style to how I would have so is not "instinctive" for me.
I have a Google Sheet (example) with a basic vlookup to create a summable column. It returns "#N/A" for every search key not found, and attaches the following error to those cells:
Error Did not find value 'me#me.com' in VLOOKUP evaluation.
After much searching the only solution I found was to wrap the vlookup in an IF(ISNA()), given in How to link various Google spreadsheets using IMPORTRANGEs that contain VLOOKUP formulas without getting #N/A returned?. This works, but it really seems like I should not have to do this. Is there another way?
Update 2019-03-01: The best solution is now =IFNA(VLOOKUP(…), 0). See this other answer.
You can use the following formula. It will replace any #N/A value possibly returned by VLOOKUP(…) with 0.
=SUMIF(VLOOKUP(…),"<>#N/A")
How it works: This uses SUMIF() with only one value VLOOKUP(…) to sum up. So the result is that one value, but only if unequal to #N/A as per the condition argument. If the value equals #N/A however, the sum is zero. That's just how SUMIF() works: if no values match the conditions, it returns 0, not NULL, not #N/A.
Advantages:
Compared to the solution =IF(ISNA(VLOOKUP(…)),"",VLOOKUP(…)) referenced in the question, this solution contains the VLOOKUP(…) part only once. This makes the formula shorter and simpler, and avoids the mistakes that happen when editing only one of the two VLOOKUP(…) parts.
Compared to the solution =IFERROR(VLOOKUP(…)) from the other answer, errors are not suppressed as that would make detecting and debugging them more difficult. Only #N/A values are suppressed.
=IFNA(VLOOKUP(...), "")
Not sure if this has changed recently, but the IFNA implementation supports a single listing of the VLOOKUP now. That is, you don't have to wrap it in another IF.
An advantage there is that you could choose "", 0, NULL, etc. as the value to show on failure.
A simpler way to suppress error messages - of any kind - is to use the iferror wrapper:
=iferror(vlookup(A1,Lookup!A:B,2,FALSE))
I don't think there can be an easier way than that. By design, vlookup should not simply return blank if the key wasn't found: this would be indistinguishable from the situation where the key was found but the corresponding entry in second column was blank. Some error has to be thrown, and then it's up to the spreadsheet user how to handle it.
Just add
TRUE, ""
to your list of parameters, like so:
IFS(condition1, value1, condition2, value2, TRUE, "")
This works, because IFS "returns a value that corresponds to the FIRST true condition."