'Array Literal' Error in Google Sheets - Not getting the desired output - google-sheets

Here's the link to my trial sheet. Feel free to edit. The formula that I am trying to work on is in Master sheet cell A10. https://docs.google.com/spreadsheets/d/1skuD82oY9S976uPms1BvcwIrWshV2bKztSDDD76lofI/
I am trying to append certain data using arrays and query function. However, the formula throws an error saying "In ARRAY_LITERAL, an Array Literal was missing values for one or more rows." Not really sure of what's causing the error. I have used the following formula in my actual sheet (different from trial one):
FILTER('CLASS2 - Overall List'!A2:B,'CLASS2 - Overall List'!E2:E>=B2,'CLASS2 - Overall List'!E2:E<=B3,'CLASS2 - Overall List'!C2:C=B16),
IF(B4="CLASS1",
FILTER('CLASS1 - Overall List'!A2:B,'CLASS1 - Overall List'!E2:E>=B2,'CLASS1 - Overall List'!E2:E<=B3,'CLASS1 - Overall List'!C2:C=B16),
IF(B4="CLASS3",
FILTER('CLASS3 - Overall List'!A2:B,'CLASS3 - Overall List'!E2:E>=B2,'CLASS3 - Overall List'!E2:E<=B3,'CLASS3 - Overall List'!C2:C=B16),
IF(B4="All",
QUERY({FILTER('CLASS2 - Overall List'!A2:B,'CLASS2 - Overall List'!E2:E>=B2,'CLASS2 - Overall List'!E2:E<=B3,'CLASS2 - Overall List'!C2:C=B16);FILTER('CLASS1 - Overall List'!A2:B,'CLASS1 - Overall List'!E2:E>=B2,'CLASS1 - Overall List'!E2:E<=B3,'CLASS1 - Overall List'!C2:C=B16);FILTER('CLASS3 - Overall List'!A2:B,'CLASS3 - Overall List'!E2:E>=B2,'CLASS3 - Overall List'!E2:E<=B3,'CLASS3 - Overall List'!C2:C=B16)})))))```
In the final step, I am just trying to append all the results from first 3 conditions - ie, Class1, Class2 and Class3. If I modify the formula to fetch only 1 column (A2:A instead of A2:B), it's working without any issue. Am I missing something here?

Try
=IF(B3="ClassA",FILTER(ClassA!A2:B,ClassA!C2:C=B7,ClassA!E2:E>=B1,ClassA!E2:E<=B2),
IF(B3="ClassB",FILTER(ClassB!A2:B,ClassB!C2:C=B7,ClassB!E2:E>=B1,ClassB!E2:E<=B2),
IF(B3="All",query({
iferror(FILTER(ClassA!A2:B,ClassA!C2:C=B7,ClassA!E2:E>=B1,ClassA!E2:E<=B2),{"",""});
iferror(FILTER(ClassB!A2:B,ClassB!C2:C=B7,ClassB!E2:E>=B1,ClassB!E2:E<=B2),{"",""})
}),"where Col1 is not null")))
in case of error, you need to fill 2 cells by blanks or error message

Related

Mathematical order of operations problem? or something else?

Sample gsheet
https://docs.google.com/spreadsheets/d/1lRs27-1vcF-8SV8l2lwOHYtEVJewn7iurqm93C-KtcI/edit?usp=sharing
I think this two formula below supposed to give the same result, and it did when calculate separately. But when I composed the formula together with other cells, it gives 2 difference result. Somebody could explain the logic behind please? Thank You!
=SUM(ARRAYFORMULA($C$5:$C10*$D$5:$D10*$E$5:$E10))-SUM($F$5:$F10)
=SUM(ARRAYFORMULA($C$5:$C10*$D$5:$D10*$E$5:$E10-$F$5:$F10))
Logic is simple - for first formula:
=H2+I2+J2-SUM(ARRAYFORMULA($C$5:$C10*$D$5:$D10*$E$5:$E10))-SUM($F$5:$F10)
replacing ranges with values you get:
=79,478.14 - 41,000.00 - 64.16 => 38,413.98
for second formula:
=H2+I2+J2-SUM(ARRAYFORMULA($C$5:$C10*$D$5:$D10*$E$5:$E10-$F$5:$F10))
with values you get:
=79,478.14 - 40,935.84 => 38,542.30
You should use parentheses to get the same result:
=H2+I2+J2-(SUM(ARRAYFORMULA($C$5:$C10*$D$5:$D10*$E$5:$E10))-SUM($F$5:$F10))
with values :
=79,478.14 - (41,000.00 - 64.16) => 38,542.30

Google Sheet formula error when added further condition

Trying to add a condition in the following formula that IF(F3:F<DATE(2020,6,30),13 whenever i tried to add it gives me an error.
Your help will be highly appreciated
=ArrayFormula(if(len(G3:G),ROUND(IF(LEN(F3:F),IF(G3:G="Confirmed",13 - MONTH(DATEVALUE(TEXT(F3:F,"mmm")&" 1"))) * 13/12,IF(G3:G="Probation",0)))),""))
I broken the formula and make it work for me but how to do the same thing with above one
=IF(AND(F3:F<DATE(2020,6,30),G3:G="Confirmed"),13,(13 - MONTH(DATEVALUE(TEXT(F3:F,"mmm")&" 1"))) * 13/12
)
Sheet link
https://docs.google.com/spreadsheets/d/1IGSRMfqDODklJdPS4_TIMlIZJSM2JXqf_4pWOGjav4I/edit#gid=0
Issues
1.) You placed your "Probation" condition outside an IF statement does generating the error of "Wrong number of arguments..."
2.) AND formula cannot be used inside an ARRAYFORMULA because it will end the whole array together which will generate unexpected result.
Solution
1.) You can place your "Probation" condition before the "Confirmed"&DATE condition right after the IF(LEN(F3:F)..
2.) Instead of using AND. You can multiply both conditions which will return 1 if both conditions are TRUE.
You can use the formula below. This is working as expected on my end:
=ArrayFormula(if(len(G3:G),ROUND(IF(LEN(F3:F),IF(G3:G="Probation",0,IF(F3:F<DATE(2020,6,30)*(G3:G="Confirmed"),13,(13 - MONTH(DATEVALUE(TEXT(F3:F,"mmm")&" 1"))) * 13/12))),"")))

Sumifs #ref error in google sheet - unexplainable

I have this very strange error which makes no sense to me.
I am using below formula to sum up sales values based on 2 criteria (one being month and the other one category)
=sumifs(Sales!$S:$S,Sales!$H:$H,D3,Sales!$Q:$Q,$A$12)
This formula works absolutely fine if I set cell D3 to 52020 (i.e. sum up all sales for may) - however, if I change the value to 62020 I am getting a ref error (same if I enter the value directly into the formula rather than using a cell). I tried other values and it looks like that only 62020 produces an error.
There are sales with 62020. In any case, this makes absolutely no sense to me especially given the error seems to come due to a Criteria not a range/ref.
I wonder if this is a bug (but probably I am missing something). Any ideas?
could be that for some reason your sheets converts it to date
62020 = 10/19/2069
try:
=INDEX(SUMIFS(Sales!S:S, Sales!H:H*1, D3*1, Sales!Q:Q, A12))

How to implement a custom number format that will look like "30c - $19.70"

I'm creating a spreadsheet for keeping track of my stock trades. This column will be called "Risk" and it will show how much money I want to risk per share on trade and at what price I will have to close the trade at if prices go against my position. So, for example, if I bought shares of Ford at $20 and was willing to risk losing 30 cents per share before closing the trade, I want to be able to type "30 19.70" in a cell and have the custom number format change it to "30c - $19.70". How do I implement this?
I have tried using the following custom number format on Google Spreadsheets but it doesn't work:
0 "c - " $0.00
I input the following into a cell: 30 19.70
I want this result to be: 30c - $19.70
But I'm getting this output: 30 19.70
unfortunately, this is not possible for several reasons:
your entry: 30 19.70 is not a number. it's a text string. that's why 0 "c - " $0.00 will never work because those zeros are trying to find numbers to catch up on them, but your entry is not a number.
text can't be divided in between with "c - ". you can have #"c - " or "c - "#, but #"c - "#.# will output: 30 19.70c - $30 19.70.30 19.70
best you can do is to enter 30 in one cell and 19.70 in another cell and use a formula in a 3rd cell:
=A145&"c - $"&TEXT(B145, "##.#0")
or: =JOIN("c - $",INDEX(SPLIT(A150," "),1,1),TEXT(INDEX(SPLIT(A150," "),1,2),"##.#0"))

Countifs formula

I am new to google sheets. I have a spreadsheet with two tabs that are involved with this question:
DB - Dental
RPT - Billing Dental
On the RPT tab, I am trying to create a countifs formula to count the number of patient records for which no billing activity has yet occurred.
My basic countifs formula looks like this:
=countifs('DB - Dental'!F3:F845,A3,'DB - Dental'!AC3:AC845,"")
Row 845 is the last row of data entered into the DB tab.
I now want to replace the 845 reference in this formula and make it instead automatically figure out what the last row number in my DB tab is so it will dynamically grow as more records are entered into the spreadsheet.
The formula I have for figuring out the last row of data in the DB tab is this:
=(max(arrayformula(if('DB - Dental'!A:A<>"",row('DB - Dental'!A:A),""))))
Both formulas work separately. The question is how can I merge them together so the countif function reads from row 3 to the last row of data in the DB tab?
Thank you very much for your help!
Assumptions|
It would be much easier to have some sample data you are working on. Based on information you gave, the second formula you have written -
=(max(arrayformula(if('DB - Dental'!A:A<>"",row('DB - Dental'!A:A),""))))
just counts rows that are not empty in A column.
If that is true,
then you would archive the same just using
=COUNTA('DB - Dental'!A:A)
From this point you need to use this to generate final range in you basic countifs formula. You need INDIRECT function to be involved, like that:
INDIRECT("'DB - Dental'!F3:F"&COUNTA("'DB - Dental'!A:A"))
Final formula
=countifs(
INDIRECT("'DB - Dental'!F3:F" & COUNTA("'DB - Dental'!A:A")),A3,
INDIRECT("'DB - Dental'!AC3:AC" & COUNTA("'DB - Dental'!A:A")),""
)
Should work - but if you gave your sample data, then I could verify it first... :)

Resources