using if statement to check for text value - google-sheets-query

in google sheets im trying to do a formula that first checks if there is text in a cell elsewhere on the page example:
A1 contains text = true then C1/B1 output to D1
A1 contains text = false then D1 = 0
reason im using this is im pulling values from a 2nd sheet using a drop down and populating the results on page 1 but when there is no data to pull for d1 it flags an error #DIV/0! but it has to try pull these rows of data as some data will use the rows.
thanks in advance

Put this in D1:
=IF(A1="",C1/B1,0)

Related

How to crossmatch data of a column with multiple column and take action if it matched?

Here I have two sheets in google spreadsheet.
Please check the screenshot
I would like to automatically search all the single data of column A of Sheet 2 in Column A and C of Sheet 1 and if it matched it would make the checkboxes ticked on column B and D of sheet 1 and if its not matched it would leave it as it was. I have attached that screenshot which is the result I expect. Is there any functions or script to do this?
I'm not familiar with such staffs. A help would be greatly appreciated.
Thanks
you do not need to write a script for this - an array formula can do it all
to the formula start working - you need to clear out everything from the range B1:B7 . then paste the formula =ArrayFormula(IFNA(VLOOKUP(A1:A7,Sheet2!$A:$A,1,false),)=A1:A7) into cell B1, then select range B1:B7 and paste checkboxes through the menu Insert - Checkbox
the formula for the range D1:D7 is inserted in the same way
=ArrayFormula(IFNA(VLOOKUP(C1:C7,Sheet2!$A:$A,1,false),)=C1:C7)
after some thought, came to the conclusion that the formulas could be much simpler
=ArrayFormula(COUNTIF(Sheet2!$A:$A,A1:A7)>0) for cell B1
=ArrayFormula(COUNTIF(Sheet2!$A:$A,C1:C7)>0) for cell D1

Google Sheets Query ignoring rules randomly, is not null?

struggling to understand what is happening here.
I have the following query in google sheets:
=query(datarange, "select AW where AX >= 0 AND "&I4&" is not null", 0)
I4 in this instance is returning a column value, for example BH.
The data contains 0, 1, 2,3 and so on.
This query is working perfectly a lot of the time, but sometimes it returns all the results but ignores the 0s. I need it to return all values that are not null.
Thanks in advance.
Example of query working and not working here
Sheet Here: https://docs.google.com/spreadsheets/d/1l6mkDbONM1Nx0fccYCvtfjPawg9GXesVdCVZUwIllcY/edit#gid=933451035
I think the issue is the mix of data type in columns ( - in place of 0).
Looking at the 'Clark, Jordan' tab as an example, try the following:
Remove the QUERY formulas from cells A9, B9 and C9.
Put the following in A9:
=arrayformula({Disposals!A7:B12,value(substitute(Disposals!I7:I12,"-",0))})
You can always wrap a QUERY round this array if you need to. For instance, you could sort the array using:
=query(arrayformula({Disposals!A7:B12,value(substitute(Disposals!I7:I12,"-","0"))}),"order by Col3" ,0)
It depends if you want a separate column on the right for 'Reverse'.
Th above is probably going to be easier to manage than trying to convert '-' to 0 on the 'Behinds' tab.
The reason that the formula in cell L10 on 'Dahlhaus, Luke' is not working is because on 'Behinds' tab, your formula in cell BH7 is converting the hyphen to text '0'.
=if(L7 = "-", "0", L8) should be =if(L7 = "-", 0, L7)
However, this is a lot of manual work, having to use formula in every cell.
It would be more manageable to use =arrayformula(if(L7:L = "-", 0, L7:L)) in cell BH7 and remove all other formula below.

Need to change a sentence to add a word from a list in separate sheet

Hi there and thank you for any support received in advance!
I have a Google Sheets document that has a list of towns in it in two columns on a separate tab and a series of default statements.
I would like to be able to run some form of script or code that automatically changes the "XXXX" and the "ZZZZ" to the appropriate text, as listed in the list of towns (on the second sheet) in any sentence and replaces it with a word from the list of towns. If someone is able to help I would really appreciate it and you can change that document as much as you'd like (it is a demo that I have set up for the purpose of asking this question). I would also appreciate a short explanation as to how you achieve the required result so I can learn and apply this in the future (without having to come back to S.O every time).
NOTE: I need to apply this for 1719 rows in the sheet, and cascade all of the text down it.
Edit: I have completed the first line of the sheet and completed it to the way we need it to be.
Change XXXXXX to ZZZZ and use newest formula
=arrayformula(if(len(C3:C), substitute(substitute(B2, "XXXX",list!A2:A),"ZZZZ",list!B2:B),))
Now no mixing XXXX and XXXXXX
For column B put this formula in cell B3.
For column D put formula in cell D3 and only change B2 to D2.
For column F put formula in cell F3 and only change B2 to F2.
For column L put formula in cell L3 and only change B2 to L2.
For column M put formula in cell M3 and only change B2 to M2. etc.
Like this do for every column you need.
Like other question now you do it 2 times. One for XXXX and one more for ZZZZ. That is why you do substitute again.
Because it is other tab you use list! for ranges there.

Copy a column data into next tab with 5 blank cells in b/w each cell data

Is there any formula to do this or do I need an apps script
A simple A2:A_data in 1st tab needs to be copied to tab 2_A2:A with 5 blank cells in between each data cell!!
**there are no blanks in the to-be-copied A2:A data
I took your answer from the comment:
=TRANSPOSE(SPLIT(ArrayFormula(JOIN(" , , , , ,",FILTER(A:A, A:A <> ""))),","))
I like this formula, but I also suggest more general solution:
=TRANSPOSE(SPLIT(ArrayFormula(JOIN(REPT(", ",5),FILTER(A:A, A:A <> ""))),","))
where number 5 in REPT(", ",5) is a number of times to repeat blank line
Also there's shorter version:
=TRANSPOSE(SPLIT(JOIN("",FILTER(A:A&REPT(", ",5),A:A<>"")),",",0))

Delete duplicate rows in calc?

I have a column in openoffice calc with a set of codes. For example:
B1
B1
Br
Bh
Ht
C3
C3
So what I would like to do is delete all the duplicates so I am left with just:
Br
Bh
Ht
Any help much appreciated.
Cheers
Select the entire range containing data to filter, then click on the menu
Data > Filter > Standard Filter
and:
Use a condition that is always TRUE, like field1 = Not empty
Click on the button more, select Remove Duplicate, select Copy to and put the address of an empty cell
The whole range (without duplicate) will be analyzed and copied at that new address.
source
Or
For both Calc and Excel the quick and dirty solution would be
=COUNTIF($A:$A;$A1)
copied down for every entry in Column A.
All entries where the result is 1 can be filtered as new values.
Calc syntax for COUNTIF:
Source