Require a COUNTIF Formulation that is not available on search option - countif

Could you please help I need a COUNTIF formula.
The range is Cell A1 to Cell N1, the criteria is if there is a text with A the value of A should be 1 in the answer, and if the text is H the value should be 0.5?

Please try:
=COUNTIF(A1:N1,"A")+COUNTIF(A1:N1,"H")*0.5
though you might be better off entering 1 instead of A and .5 instead of H and just using =SUM.
This is not case sensitive (A or a should work equally).

Related

Can I show the results of COUNTIF in one column only if there is data in another column?

I have a spreadsheet with multiple sheets.
Sheet A is generated from a template, and it is where users will enter in data to be formatted into a report; it will be deleted after that report is submitted.
As people enter info into Column A of Sheet A, they don't have to enter client information if we already have them entered in this spreadsheet, but otherwise they need to go over to Sheet B and enter it in.
To make it easier for them (so they don't have to check every time, or go back and enter info later after getting an error generating the report), I have used conditional formatting. The way it works is, column Z is set up as a helper column, and uses a "COUNTIF" function to check if the client ID in Sheet A, Column A is found in Sheet B, Column C. Sheet A Column Z returns 0 or 1 (or, theoretically, more than one if we had duplicates), and then Sheet A column A has conditional formatting based on Column Z's value-- if the client is already in, the cell for client ID turns green after they type it; if not, it turns red.
It works great! However, I am adding scripts to these sheets, and looping through them. This helper column is filled from Z1 to Z1000, which means I can't use sheet.maxRow() to get the last row.
I see plenty of workarounds on the script side, but I was wondering if anyone has a clever way to input a value into the helper column Z ONLY IF the corresponding cell (same row) in column A has a value using spreadsheet formulas.
I suspect that an array formula with a filter might do it, but I have little experience with either and can't get anything to work out.
Thanks for your help!
You can use this expression with INDEX, MAX and ROW to make an ARRAYFORMULA only expandable until the last cell with value in column:
A2:INDEX(A2:A,MAX(ROW(A2:A)*(A2:A<>"")))
It will go from A2 to the maximum number of row in A in which A is different than null (that's why both conditions are multiplied).
Then you can set a formula like this in Z2 (check the ranges in case something is not right from reading your text, and delete all other formulas in Z too in case you weren't using an arrayformula already):
=BYROW(A2:INDEX(A2:A,MAX(ROW(A2:A)*(A2:A<>""))),LAMBDA(each,IF(each="","",COUNTIF('Sheet B'!C:C,each))))

subtract from number IF statment

Sorry if this is a very basic question - but I'm struggling how to find this on a google search.
Essentially what I need is a way to keep subtracting from a number if an condition is met.
I can do the IF statement fine for one cell, but am unsure how to keep deducting from the value.
=IF(D9= "Y", 100-E9)
The screenshot below explains it better. Essentially if there is a 'Y' then the figure on the right should subtract from 100. If 'N' then nothing should happen.
Thanks for any help given in advance.
enter image description here
Sure you can. Sounds like you want to use SUMIF combined with a subtraction.
For your case, the formula will likely be:
=<start value>-SUMIF(<range of Y/N>, <condition>, <range of values>)
e.g. for a sheet with:
either Y or N in column A, from A1 to A10
numeric values in column B, from B1 to B10
where the value in B1 is to be subtracted if A1 is Y
the start value is 100
You would use =100-SUMIF(A1:A10, "=Y", B1:B10)

Countif Formula to exclude Duplicates

I sought help regarding this once, but I failed to outline my problem.
This time I am happy to share the sheet with dummy data in hope it explains my problem a bit better: Link to the sheet
My issue is the following:
In column E I am counting the number of opportunities for a rep (listed in column A). The data I am considering is in a separate sheet named "Pipeline".
I do this with the countif formula and I use additional criteria to filter on date as well. My dates for february are in B4 and G4, because I only want to see opportunities in February.
My formula looks like this:
=countIFS(Pipeline!$A:$A,$A7,Pipeline!$F:$F,">="&$B$4,Pipeline!$F:$F,"<="&$G$4)
This works perfectly fine. However, sometimes I have two opportunities in my pipeline sheet with the same name (these are split opportunities). If an opportunity has the same name it should be counted only once. I can't seem to find an easy way to update my countif formula.
In the dummy sheet I shared above, you can see that Peter has two "New - CC Tech" opportunities. I want this to count as one opportunity. Everything I googled so far suggests using rather complex formulas, which is not so easy as I have multiple criteria in the formula that I need to filter my results (such as name of the rep and dates). Please feel free to suggest a solution within the sheet above and play around with it.
I really appreciate the help!
Try this ('unique' based on A,B and F)
=query(unique({Pipeline!A:B,Pipeline!F:F}),"select count(Col1) where Col1='"&A7&"' and Col3>=DATE'"&TEXT($B$4,"yyyy-MM-dd")&"' and Col3<=DATE'"&TEXT($G$4,"yyyy-MM-dd")&"' label count(Col1) '' ")
or, if you consider that the date could be different between two lines ('unique' based only on A and B, the date could be different but within the limits)
=query(unique({Pipeline!A$2:B,arrayformula((Pipeline!F$2:F>=$B$4)*(Pipeline!F$2:F<=$G$4))}),"select count(Col1) where Col1='"&A7&"' and Col3>0 label count(Col1) '' ")
In this second formula, we construct a matrix with A, B and 0/1 (which is the result of the question: is F within limits), then we apply unique and we query when Col3 is equal to 1 and Col1 the name we are looking for

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.

Google Sheets -fill a cell with contents of a different cell when not blank

I am new to Google Sheets. I and am trying to make a spreadsheet where column A has a list of words and when I type an x or something in a cell in a different column (lets say column B)it automatically fills with the word contained in column A in the same row. I have tried to use =IF(CELL(not(empty... with different arguments but I really don't know what I am doing. I'm trying to read up on Google Apps Script and figure out a way to write a macro to accomplish this but again, I'm not sure if I need a macro. I would appreciate any help I can get on this.
The answer above is also correct, alternatively you can use the following formula:
if(B1 <> "",B1, "")
Enter the above formula into cell A1 and drag it down column A as far as it needs to be.
Broken down this says, if B1 is not blank, then make A1 the same as B1, else make A1 blank.
Here is Google Script unnecessary.
Just use Formula. Here you can put to A1:
=B1
and in A1 will be the same word as in B1. If you need condition, try to A1 set:
="My magic word is: " & IF(ISBLANK(B1),"(nothing)",B1)