Glitchy Data Validation Custom Formula - google-sheets

=COUNTIF(IMPORTRANGE("[spreadsheet_id]", "$L:$L"), L2) <= 1
I'm using the above formula in my data validation rule to make sure all values are unique. The sheet referenced is a master list of different ranges combined (also using IMPORTRANGE) so I can check for uniqueness across multiple spreadsheets.
The formula is fine, but the validation does not work normally. I made sure I authorized access to the spreadsheet beforehand, but I've noticed some glitchy behavior. When I take that same formula and put it in a cell on the sheet and then resave the data validation rule, it somehow seems to get it working. But when I remove it again, it doesn't.
Is this normal behavior? Do I have to have a cell with the same formula on my sheet for it to work?

Related

my =Importrange Formula on Google sheet doesn't work with multiple Xlookups in the sheet

I'm making a budget sheet on google sheets. When I use importrange on my google sheet, it works perfectly fine. However when I use an Xlookup in a different tab and different cell, the Importrange fails and gets stuck on loading. I'm not sure why... It may be because they loosely reference each other? I'm using Xlookups to sum a range which includes some of the imported data... But in my mind, that shouldn't affect the Importrange at all. If you delete all the xlookups, the importrange pushes through, and if there is only 1 Xlookup in the entire sheet, Importrange still works... Can anyone help??? I've linked the sheet below so that you can play with it. You can change the links for the importrange freely.
FYI you have to delete the importrange / refresh the page after each change as the importrange will just keep the data their until there is a change on either the data side or sheet side.
Link to the Sheet
I tried deleting all Xlookups and and changing the Importange Range to lessen the impact
I tried array constraining other formulas in the sheet because I thought it was stuck on too many calculations
I tried simplifying the Xlookup formulas to set ranges.
you can build your IMPORTRANGE like:
=ARRAYFORMULA(IFERROR(NOW()/0)&IMPORTRANGE(D2; "A1:A4"))
and with:
changes won't be instant of course but they will flow more often

Preventing API edits from breaking arrayformula columns

I have a Google Sheet that I'm using as a database for a an app I am building in AppSmith. Really just an interface for people to work with the sheet in a controlled manner.
I'm using the Google Sheet because I'm familiar with layering formulas to make it work the way I want it to work. I have a number of columns that start with an ARRAYFORMULA that gives the name of the column in row 1, blank in blank rows that should be blank, and some programmed information in other rows.
This works great as long as I am working from the spreadsheet or reading/adding rows from the app.
However, when I try to edit the row from the app, the API update will take the "50" that it sees in the column and actually put "50" in the cell, breaking the arrayformula.
Is there any way to prevent API calls from actually editing that column? Or to automatically clear the cell and let the arrayformula expand again?
I found a temporary workaround to push "" for the column(s) I know are arrays, but it seems vulnerable to complications if I add other array columns later, or want to make another form in the app that also updates the sheet.
As a "rule of thumb", avoid having formulas on sheets being used as "databases" (top row used for field names, 2nd row and below used for data). If you really need to use formulas in the spreadsheet instead of doing the calculations on the "APP", add them on a "mirror" sheet.
This is a common recommendation when using ARRAYFORMULAS to do calculations with data comming from Google Forms.
If you think that creating a "mirror" sheet might cause more problems than benefits, if your "APP" is able to limit the number of columns being edited, put the formulas to the right of the last column linked to the app.
Related
Make Google Spreadsheet Formula Repeat Infinitely

Google sheets, two-sheet dependent conditional formatting

My problem is probably trivial ... However, I was looking for similar problems and their solutions either do not work for me or I can not apply them.
I have 2 sheets - SheetA and SheetB. They are identical. I want to select every cell in SheetA that is no longer identical to Sheet B.
I was able to use (found here on Stack Overflow) such a function in conditional formatting:
= A1 <> INDIRECT ("SheetB! A" & ROW ())
It works if the range is column A. I know that I can apply this function to each column separately, but there is certainly a way that I can apply the same formula to the whole worksheet.
Will there be anyone who can show me the correct formula?
Edit: I tried to use above formula to every column... And my file become to work very slow... So whoever wants to do the same... think again.
After some tries I decided to move everything from SheetB to SheetA. I paste it a 1000 rows under data of Sheet A. Works fine without "indirect" function. No slow downs. It is not a perfect solution but it works.
But even after my problem is solved different way, I would like to know what is the correct formula for my problem... it might be useful for the future with smaller amount of data.
Solved ;)
You should be able to use the Address function to get the address of the current cell from its row and column:
=A1<>indirect("sheetB!"&address(row(),column()))
or for case-sensitive match:
=not(exact(A1,indirect("sheetB!"&address(row(),column()))))

Google Sheet Array Formula to automatically transpose responses from a Google Form into a single cell

I want to tweak an Array Formula that I'm trying to use to transpose a set of responses from a Google Form into a single 'list' in a cell in the linked Google Sheet.
Here is a simplified mock-up of the Google Sheet: https://docs.google.com/spreadsheets/d/1BKgjGK2RbXC5FkCgBOU53dLEb3fDeQADujenrqRgnT0/edit?usp=sharing
As you can see, I have a working Array Formula 'hidden' in the header for Column A, which takes the content from columns B:K in each row and transposes them with line breaks to make a nice neat list in the first cell at the start of each row (A2, A3, A4, etc.) Here is the Array Formula for ease of reference:
=ARRAYFORMULA({"Points to Develop";
transpose(query(transpose ($B$2:$B&CHAR(10)&$C$2:$C&CHAR(10)&$D$2:$D&CHAR(10)&$E$2:$E&CHAR(10)&$F$2:$F&CHAR(10)&$G$2:$G&CHAR(10)&$H$2:$H&CHAR(10)&$I$2:$I&CHAR(10)&$J$2:$J&CHAR(10)&$K$2:$K)
))})
The problem I'm having is that the formula stops working as soon as a new Google Form is submitted, as the new row of responses arrives at the top and 'pushes the formula down'/throws everything out of alignment, when all I want is for it to stay in place and run automatically every time a Form is submitted. As you can probably gauge by my limited technical terminology, I'm very much a novice at this!
How can I fix this formula, or is there a simpler or better alternative that will achieve the same results?
As often happens in life, the nature of the problem turned out to be the source of the solution. Here’s a condensed version of my thoughts as I slowly found my way to an answer (you can almost hear the hamster wheels turning in my head!):
The problem with formulas in a Google Sheet linked to a Google Form is that each new entry/submission from the form always arrives in Row 2 …
In fact, the only thing that stays ‘in place’ in the Google Sheet is the Header Row/Row 1 …
So, rather than using a formula that refers to a ‘Row 2’ that will become ‘Row 3/4/5/etc.’ as new Google Forms are submitted, I should use a formula that always refers to Row 1, that is, by using OFFSET
The obvious (if inelegant) formula that resulted from this is [I've also placed this in the final column in the Google Sheet that I linked to in my original question]:
= ARRAYFORMULA({"Points to Develop [Working OFFSET Formula]"; transpose(query(transpose(OFFSET(A1:A,1,1)&CHAR(10)&OFFSET(A1:A,1,2)&CHAR(10)&OFFSET(A1:A,1,3)&CHAR(10)&OFFSET(A1:A,1,4)&CHAR(10)&OFFSET(A1:A,1,5)&CHAR(10)&OFFSET(A1:A,1,6)&CHAR(10)&OFFSET(A1:A,1,7)&CHAR(10)&OFFSET(A1:A,1,8)&CHAR(10)&OFFSET(A1:A,1,9)&CHAR(10)&OFFSET(A1:A,1,10)))) })
I am sure that there are neater ways of getting to the same result, but this is one that works for me … and is within my levels of comprehension, so I can fine-tune and fix it as needed.

Data Validation, Complex, based on another sheet

Sample sheet here.
Have 2 sheets; DataTemplate stores the validation keys and DataValidation is the sheet that should include data validation based on said keys.
Eg: DataValidation!B11:E17 is validated against DataTemplate!B11:E17 (please see sample)
Sample validation requirements:
IF coressponding DataTemplate value == -500 then Cell must be blank
IF coressponding DataTemplate value == -200 then Cell must be blank or positive number
IF coressponding DataTemplate value > 0 then Cell must be a number between 0..1 OR a string in [ "A", "B", "C" ]
I've attemped this with formulae like below but other than very simple validation available on the net, I've not been able to make anything work.
=SWITCH(INDIRECT("DataTemplate!D11:E17"),-500,ISBLANK(D11),-200,OR(ISNUMBER(D11),ISBLANK(D11),OR(ISNUMBER(D11),IFERROR(MATCH(D11,SPLIT("A,B,C",","),FALSE),FALSE)>0)
EDIT; solved thanks to Jeremy Kahan (below).
My issue was, I was trying to apply Conditional Formatting rules to Conditional Validation, but apparently they are quite different in terms of their application (I do believe). Eg: you can directly access cells in other sheets, you write a normal formula for the top left cell of the range you are applying to. My actual validation formula is given below.
=SWITCH(WorkArrivals!D11,
-500,ISBLANK(D11),
-400,ISBLANK(D11),
-200,AND(NOT(ISBLANK(D11)),OR(AND(ISNUMBER(D11),D11>0,D11<1),NOT(ISERROR(SEARCH("|"&D11&"|","|absent|sick|annual|family|domtravel|inttravel|"))))),
-100,OR(ISBLANK(D11),AND(ISNUMBER(D11),D11>0,D11<1),NOT(ISERROR(SEARCH("|"&D11&"|","|domtravel|inttravel|")))),
AND(NOT(ISBLANK(D11)),OR(AND(ISNUMBER(D11),D11>0,D11<1),NOT(ISERROR(SEARCH("|"&D11&"|","|absent|sick|annual|family|domtravel|inttravel|")))))
)
Tips:
No way to validate NOT(ISBLANK()) as (it appears) validation is triggered when data is entered ONLY.
Similar to Conditional Formatting, it appears that the whole (applied) range is validated and NOT just the cell that was updated. There is a (background active progress bar) lag (~2s for range(1000 rows, 15 cols) - so use with caution on large ranges. #Google could make this smarter ?
Solved thanks to Jeremy Kahan (below). For the benefit of other users;
My issue was, I was trying to apply Conditional Formatting rules to Conditional Validation, but apparently they are quite different in terms of their application (I do believe). Eg: you can directly access cells in other sheets, you write a normal formula for the top left cell of the range you are applying to. My actual validation formula is given below.
=SWITCH(WorkArrivals!D11,
-500,ISBLANK(D11),
-400,ISBLANK(D11),
-200,AND(NOT(ISBLANK(D11)),OR(AND(ISNUMBER(D11),D11>0,D11<1),NOT(ISERROR(SEARCH("|"&D11&"|","|absent|sick|annual|family|domtravel|inttravel|"))))),
-100,OR(ISBLANK(D11),AND(ISNUMBER(D11),D11>0,D11<1),NOT(ISERROR(SEARCH("|"&D11&"|","|domtravel|inttravel|")))),
AND(NOT(ISBLANK(D11)),OR(AND(ISNUMBER(D11),D11>0,D11<1),NOT(ISERROR(SEARCH("|"&D11&"|","|absent|sick|annual|family|domtravel|inttravel|")))))
)
Tips:
No way to validate NOT(ISBLANK()) as (it appears) validation is triggered when data is entered ONLY.
Similar to Conditional Formatting, it appears that the whole (applied) range is validated and NOT just the cell that was updated. There is a (background active progress bar) lag (~2s for range(1000 rows, 15 cols) - so use with caution on large ranges. #Google could make this smarter ?

Resources