Hard-coded comparisons - google-sheets

I am making a calculator style spreadsheet for quickly and easily calculating normally tedious equations into a few simple clicks. However, I have hit a snag.
In B3 I have a list of various possible selections for the user. Depending on what they select, multitudes of other cells will change values to display the correct and needed information.
My first attempt to try to get a cell to format dependent upon the contents of B3 used:
=IF(ISNUMBER(SEARCH("Plate",B3)),"Quake",ISNUMBER(SEARCH("Cloth",B3)),"Ocean",ISNUMBER(SEARCH("Leather",B3)),"Typhoon",ISNUMBER(SEARCH("Neck",B3)),"Earth",ISNUMBER(SEARCH("ring",B3)),"Earth",ISNUMBER(SEARCH("Dagger",B3)),"Mountain",ISNUMBER(SEARCH("Sword",B3)),"Summer",ISNUMBER(SEARCH("Katana",B3)),"Sky",ISNUMBER(SEARCH("Club",B3)),"Autumn",ISNUMBER(SEARCH("Shortspear",B3)),"Winter",ISNUMBER(SEARCH("Axe",B3)),"Typhoon",ISNUMBER(SEARCH("Greatsword",B3)),"Desert",ISNUMBER(SEARCH("Nodachi",B3)),"Lightning",ISNUMBER(SEARCH("Greataxe",B3)),"Desert",ISNUMBER(SEARCH("Greatclub",B3)),"Sunset",ISNUMBER(SEARCH("Longspear",B3)),"Squall",ISNUMBER(SEARCH("Shield",B3)),"Quake",ISNUMBER(SEARCH("Bow",B3)),"Volcano",ISNUMBER(SEARCH("Scepter",B3)),"Meadow",ISNUMBER(SEARCH("Staff",B3)),"Ocean","")
The problem I had is that IF expects three arguments maximum.
Is there a way to circumvent this, possibly by breaking up the comparison using many OR statements?

You can nest IF statements. The syntax is indeed three arguments, say =IF(test,a,z). So if the first test fails you may incorporate a second for that case: =IF(test1,a,IF(test2,b,z)) and a third =IF(test1,a,IF(test2,b,IF(test3,c,z))) and so on.

Related

Transform comma separated google form answers to multiple lines in spreadsheet

I have made a google form to which some answers are formatted as comma separated strings inside the automatically populated google spreadsheet. I would like to read from this sheet to another sheet and reformat the answers so that each comma separated answer is shown on a new row. I have tried to apply an ARRAYFORMULA that reads from the original sheet and then use a solution that uses SPLIT and TRANSPOSE the cell content, however combined with the ARRAYFORMULA this fails since it would overwrite contents in other cells.
Here is an example spreadsheet with the responses, a solution sheet, and a desired results sheet. https://docs.google.com/spreadsheets/d/1r_l5fVJ9lGfpubO2o3pXicV7JlZWmANjwSgNi7_DL0A
Any suggestions for how I can achieve the end result?
Okay, I assume this isn't really what you want, but visually it looks okay...
Try this formula:
={{'Form responses'!A2:A3},ArrayFormula(regexreplace('Form responses'!B2:E3,", ",CHAR(10)))}
Then format the cells so that the cell contents are TOP-aligned, instead of the default BOTTOM-aligned.
Realistically, I imagine that you want each question answer split into multiple cells. But if your data responses really contain letter values separated by commas, as you've indicated, you can still search through those cells to find whether an answer contains a certain value. It all depends on why you want the results structured the way you do.
If you can clarify what you want to do with the form results, instead of just appearing vertically for each question, perhaps we can provide a full solution for that requirement?
UPDATE1:
Okay, I may be getting close. I can get your data transformed to look like the following:
This would let you do the analysis that you want, by searching for Q.1 (question 1 responses) in the first column, and then all the answers in the third column, along with the owner in column 2. And from this, it will also definitely be possible to put the results in the exact form you want. It just may take an intermediate step.
UPDATE2:
Okay, I think I have something you can use. I can convert your data to either of the following two layouts.
The one on the right is closest to what you asked for, with the exception that the answers on the right are bottom aligned, with blanks above. But you can still process them for analysis, with queries. I honestly think having the user identifier (email address) on each row would make things simpler, but I can provide it either way.
The layout on the left is more of a traditional database layout, and would make analysis very simple. Each row has the date and email identifiers, the question number, and the answer (or one of the answers) to that question, from that user.
If this is helpful, it might be best if you enabled your sample sheet to allow us to edit it, to enable me to implement it in your sheet. But here is my sample sheet, in case anyone wants to look through it. Note that the main formula to reformat the data, in Solution!B3, could benefit from a lot of cleanup, and is probably nowhere near the best way to achieve this. Just throwing up one possible solution...
I'll try to add some explantion for the formula at some point, but ask if you have any questions.

How do I use Number Formatting in Google Sheets to display an UNSIMPLIFIED, NON-reduced fraction?

I'm building a progress tracking worksheet at the moment. I use Checkboxes to mark tasks as complete, and I have a simple formula to check "how many are done (true)" / "how many there are".
=COUNTIF(M7:Z7,TRUE)/(COUNTA(M7:Z7))
This was successful, and got me the percentages I needed for my progress bars, but it wasn't as useful as I was hoping because I realized I wanted to keep track of the precise quantity of remaining items in addition to the total completion rate.
So I did some digging and found the custom number formatting options in sheets, and was able to use this format to change my calculation into a non-mixed fraction:
_# ??/??
So THAT worked just fine until I realized it was treating it like, well, an actual fraction and trying to simplify it all the time. I don't want to know that I've done 1/7th of the things, I want to know that I have done 2 out of 14 things.
The reason I noticed this problem in the first place is because when it hit "100%" for one of the task categories, it went from "13/14" to just the whole number "1," which is the opposite of what I want; I want it to still show the fraction, as "14/14."
I feel like I've been spinning my wheels for so long now, I'm not sure how much better to do this WITHOUT having to completely restructure my sheet and formulas and add some stupid hidden math columns in between what I already have built.
Ideal solutions would just be some secret in the Number Formatting options. But I absolutely cannot use a static denominator in the number formatting. At this point I'm not sure what kinds of other options there are to be honest.
tl;dr
In Google Sheets, what's the best way to display an unsimplified fraction with a non-static Numerator and Denominator?
If what you want is to visualize the fraction, but not use it for further calculations. You could simply display is as a string.
For example:
this: =COUNTIF(M7:Z7,TRUE)/(COUNTA(M7:Z7))
becomes
this: =COUNTIF(M7:Z7,TRUE)&"/"&COUNTA(M7:Z7)
Note:
Keep in mind COUNTA counts all the values in the range, not just the number of rows (Which I assume is the number of tasks).
You may want to change the range passed to COUNTA to be a single column.

In Google Sheets, why does rank() treat two identical values differently?

I have a sheet with four values that I believe are all equal (i.e. =A1=B1 returns TRUE for each pair). However, when I use rank() on a list with those values, they receive different ranks.
To my knowledge, I'm not doing anything strange, such as a workaround to avoid duplicates. (In this scenario, I want duplicate ranks.) The values I'm trying to rank() were the result of a trunc(sum(...),1), so there aren't any hidden decimals places that I'm not noticing.
I'm just using rank(A1,A1:B1) and arrayformula(rank(A1:B1,A1:B1). These two formulas return different results, even.
Why is rank() treating these numbers as different? Is there some kind of flag or extra property on the cells that's not normally visible that is making them different?
This situation is a little hard to explain without seeing the data, so I've recreated the situation in this sheet:
https://docs.google.com/spreadsheets/d/1cL_15WnKgrxhJfT5lYYIg4sRAzaAzbpP7nH9hju1Rv4/edit?usp=sharing
It has to do with the Floating Point Error than with RANK.
In any case and since you are trying to see if " ...there aren't any hidden decimals places that's I'm not noticing" you could follow a different approach.
Using the ROUND function, round the values of your trunc(sum(...),1) results to however many decimal places you may need. OR
From the top menu choose Format> Number> More formats> Custom number formats and create your own
Following that, you will be able to visually spot the differences.
Additionally you can use the RANK function

Google Sheets: Repeat referencing in Formulas

=ArrayFormula(IF(A1:B6<0,0,A1:B6))
The range is referred twice. Is it possible to do this with a singular reference within a formula?
Perhaps something akin to IFERROR like IFCONDITION(range, condition, result_if_condition)
The use case is the range itself are in many cases computed using complex arrangements - so it becomes quite inconvenient/unwieldy when that same complex arrangement needs to be inserted into multiple places.
Sample sheet.
In this particular case, you can use
=ArrayFormula(text(A1:A6,"0;\0"))
so that any negative numbers are displayed as zero.
Since the result is a string, it may need to be coerced to a number for use in further calculations.
This was first suggested to me by #barry houdini - here is an example of it in use (in Excel).
EDIT by OP (as in comment below) ;
Here is the link https://support.google.com/docs/answer/56470 So if you wanted blank cells to be zero, you would set the 4th part to \0 i.e. =ArrayFormula(text(A1:A7,"0;\0;\0;\0")) because a blank cell is not a number.

SUMIFS Values from non consecutive Column Cells

I need tu sum several cells that are separated one from another, these cells are
C3,F3,I3,L3,O3,R3,U3,X3,AA3,AD3,AG3,AJ3,AM3,AP3,AS3,AV3,AY3,BB3,BE3,BH3,BK3,BN3,BQ3,BT3,BW3,BZ3,CC3,CF3,CI3,CL3,CO3
if this other cells $C$1,$F$1,$I$1,$L$1,$O$1,$R$1,$U$1,$X$1,$AA$1,$AD$1,$AG$1,$AJ$1,$AM$1,$AP$1,$AS$1,$AV$1,$AY$1,$BB$1,$BE$1,$BH$1,$BK$1,$BN$1,$BQ$1,$BT$1,$BW$1,$BZ$1,$CC$1,$CF$1,$CI$1,$CL$1,$CO$1
that are on the same column but different row are >= to certain number given and <= to other given number, but it returns #Value, can somebody help me find out what am I doing wrong?
This is the function i am writing:
=SUMIFS((C3,F3,I3,L3,O3,R3,U3,X3,AA3,AD3,AG3,AJ3,AM3,AP3,AS3,AV3,AY3,BB3,BE3,BH3,BK3,BN3,BQ3,BT3,BW3,BZ3,CC3,CF3,CI3,CL3,CO3),($C$1,$F$1,$I$1,$L$1,$O$1,$R$1,$U$1,$X$1,$AA$1,$AD$1,$AG$1,$AJ$1,$AM$1,$AP$1,$AS$1,$AV$1,$AY$1,$BB$1,$BE$1,$BH$1,$BK$1,$BN$1,$BQ$1,$BT$1,$BW$1,$BZ$1,$CC$1,$CF$1,$CI$1,$CL$1,$CO$1),">="&B55,($C$1,$F$1,$I$1,$L$1,$O$1,$R$1,$U$1,$X$1,$AA$1,$AD$1,$AG$1,$AJ$1,$AM$1,$AP$1,$AS$1,$AV$1,$AY$1,$BB$1,$BE$1,$BH$1,$BK$1,$BN$1,$BQ$1,$BT$1,$BW$1,$BZ$1,$CC$1,$CF$1,$CI$1,$CL$1,$CO$1),"<="&C55)
I'm not 100% certain, but it looks like the problem here is that SUMIFS requires arguments to be expressed in continuous-range form, e.g. A3:CO3. It looks like you're trying to work with every third column in the dataset, yes? As far as I can tell, this is best (only?) done as an array function, so that you can tell it to filter on "every third column."
Enter this in the cell, then press CTRL+SHIFT+Enter (CSE) to evaluate it as an array function:
=SUM(($A$1:$CO$1>=B55)*($A$1:$CO$1<=C55)*(MOD(COLUMN(A3:CO3),3)=0)*(A3:CO3))
You'll also need to hit CSE every time you evaluate or change it. There's a decent tutorial for array functions at https://support.office.com/en-za/article/Guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7, which may help if you're unfamiliar with them.

Resources