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

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

Related

Sum returned values from arrayformula()?

I have a long list of values in a row that I need to perform several functions/vlookups on, multiply them all together and then sum all the final values. There are over 50 different values in a row so I'm trying to come up with a way to do this without manually typing out vlookups for each column.
Here is the formula I put together, however it seems to not be returning the correct value:
=sum(arrayformula(vlookup(offset($A$1,0,{9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54}),Input!$E:$F,2,FALSE)
*offset(indirect("$A"&ROW()),0,{9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54})))
+F6+BD6
It's as if it's doing what I want for some of the values, but not summing them all. Debugging this is an absolute pain, so I'm wondering if I'm even going about this in the right way.
Is there a better way to go about this? I'm wondering if the problem is that I've got two sets of arrays embedded in this function.

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.

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.

Hard-coded comparisons

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.

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