Deduct an integer from another integer every time a checkbox is ticked - if-statement

I'm currently working on a sheet that has a "Total" stat on it which will represents slots and I want that total slots number to be deducted by "1" every time a tick box is checked.
For example, there are 8 total slots and there are 8 Tick Boxes, each time a slot is consumed, a box is ticked and the total remaining slots is deducted by 1.
What would be the best way of making this happen? I understand I can enable "iterative calculations" and have something like
=SUM(F15,IF(F15>0,SUM(IF(K15,-1,0)+IF(L15,-1,0)+IF(M15,-1,0)+IF(N15,-1,0),0)))
I'm a total spreadsheet noob but there has to be a more consolidated way to do it.
[Example image of total with tick boxes.]

try this:
=8-SUMPRODUCT(B1:E2)

Use this formula
=ArrayFormula(COUNTA(B1:E2)-SUM(IF(B1:E2=TRUE,1,0)))
Named functions - why not
Go to: Data > named functions
Lets name the function DEUCECOUNTA
and paste this in formula definition
=ArrayFormula(COUNTA(range)-SUM(IF(range=TRUE,1,0)))
Paste "range" this in the argument place holders and press enter.
Use it like this
=DEUCECOUNTA(B1:E2)
Demo

Related

How to automatically feed a cell value from a range of values, based on its matching condition with other cell value

I'm making a time-spending tracker based on the work I do every hour of the day.
Now, suppose I have 28 types of work listed in my tracker (which I also have to increase from time to time), and I have about 8 significance values that I have decided to relate to these 28 types of work, predefined.
I want that, as soon as I enter a type of work in cell 1 - I want the adjacent cell 2 to get automatically populated with a significance value (from a range of 8 values) that is pre-definitely set by me.
Every time I input a new or old occurrence of a type of work, the adjacent cell should automatically get matched with its relevant significance value & automatically get populated in real-time.
I know how to do it using IF, IFS, and IF_OR conditions, but I feel that based on the ever-expanding types of work & significance values, the above formulas will be very big, complicated, and repetitive in the future. I feel there's a more efficient way to achieve it. Also, I don't want it to be selected from a drop-down list.
Guys, please help me out with the most efficient way to handle this. TUIA :)
Also, I've added a snapshot and a sample sheet describing the problem.
Sample sheet
XLOOKUP() may work. Try-
=XLOOKUP(D2,A2:A,B2:B)
Or FILTER() function like-
=FILTER(B2:B,A2:A=D2)
You can use this formula for a whole column:
=INDEX(IFERROR(VLOOKUP(C14:C,A2:B9,2,0)))
Adapt the ranges to your actual tables in order to include in the second argument all the potential values and their significances
This is the formula, that worked for me (for anybody's reference):
I created another reference sheet, stating the types of work & their significance. From that sheet, I'm using either vlookup, filter, xlookup.Using gforms for inputting my data.
=ARRAYFORMULA(IFS(ROW(D:D)=1,"Significance",A:A="","",TRUE,VLOOKUP(D:D,Reference!$A:$B,2,0)))

Google Sheets: Sum a Value Range Within a Specified Time Frame

I'm trying to sum a range of values, within a given time frame. The time frame could be x hours, or y days, etc. An example:
So for each row, I need to sum the last hours or days as specified in cells C2:E2, which are numeric (just added formatting to show the text). Note that the datetime values do not follow any interval pattern, but are always sequential.
Although I've tried searching SO, and via Google, I haven't been able to find a way to do this.
Any suggestions would be very welcome.
[Edit]
I've added to a link to an example sheet of what I'm trying to do... pls just ask if I can add any further info!
Test Sum By Time
try:
=SUMIFS(B3:B, A3:A, ">="&NOW()-1)
=SUMIFS(B3:B, A3:A, ">="&NOW()-7)
In Google sheets, use the =TODAY() code to for today's date and put this in another cell. You could always create a new sheet (which we will call sheet3) which you hide afterwards. Let's imagine you put this in cell A1.
You can use the =IMPORTRANGE("the google sheets website link", "Sheet Name!A3:A31" to insert the values. Let's imagine you import this into B3:B31. In C3, you put =IF(REGEXMATCH(B3, A1), 1, 0).
You continue this in each cell from B4:B31, each time changing "B3" to the current row number. Then we can use the =SUM(C3:C31) code to count how many meet this condition. Let's imagine you put this in A2.
Now back to the original sheet. Use `=IMPORTRANGE("the google sheets website link", "sheet3!A2" in the cell C3.
For the other 2, I don't know, sorry!

sumproduct if a cell contains a certain value, give all results otherwise just the specified result

My issue is that I need to reference a cell (A1) which will either be the name of a state that can be found in column L, or it can be "All States" which I then want to include all results of column L. I can't work out how to include this.
=SUMPRODUCT(--(IF(A1="All States",Data!$L:$L,Data!$L:$L=A1)),Data!Q:Q)
I want to add a bunch more criteria based on the above so I don’t want to go down the route of imbedding the sumproduct in an if function because the formula will quickly become too unweildy.
You have a lot of choices. Using your initial formula I would tweak it to
(A) =SUMPRODUCT((IF($A$1="All States",1,($L$2:$L$11=$A$1)))*($Q$2:$Q$11))
But this would need to be entered as an array formula so instead of just confirming with ENTER, you need CONTROL+SHIFT+ENTER. You will know you have done it right when { } show up around your formula. Note that they cannot be added manually.
A non array type formula which would be faster I believe would be to look at your two options. You are either dealing with a single state or all states. Set up an IF check to determine if you need to sum all of column Q, or if you need to find a single value from column Q. I used the following formula:
(B) =IF(A1="all states",SUM($Q$2:$Q$11),INDEX($Q$2:$Q$11,MATCH($A$1,$L$2:$L$11,0)))
A bit of a cheat but but simplifies things, is to add a final state to the bottom of your list in L and call is "All States". In the corresponding row in Q place =sum(First Cell:Last Cell). If you do that then you can use the following formula:
(C) =SUMPRODUCT(($L$2:$L$12=$A$1)*($Q$2:$Q$12))
That are other options out there as well, just thought I would show some options.

Is The Flow Chart of the program correct?

Calculate one child’s allowance, based upon 75 cents per year old if s/he is under 10, and $1 per year if 10 or over.
I could have stated them at the beginning as well but is the use of the rate variables after the decision box correct?
Yes, it's functionally correct.
You could get rid of some of the sections if you wish by just using one variable to store the rate (rather than rate1 / rate2), and then just using the decision block to set the variable differently. You then wouldn't need to duplicate the last two statements.

Is there a 'value in time' concept in metrics, or how do I create one?

I am using metrics-clojure http://metrics-clojure.readthedocs.io/en/latest/ lists gauges, counters, meters, timers and histograms.
What I want is instead to report a number.
Very much like counter, but with a set! operation instead of just inc!/dec! or a meter that accepts a value.
One use case is processing batches of events. I can create a meter to watch the batches, but I would prefer to include the batch size such that the reporting end can use the correct units (so I can plot the number of events processed instead of the number of batches).
Another use case is wanting to produce a plot of some number that changes over time. Say again I was processing events, and I wanted to plot per event how many unique combinations of events I'd seen so far, how can I do this?
I can fake this a little bit with a gauge. I can create an atom, and have the gauge report the atom value, and set the atom value in the code... but I can't control when the gauge will report the value. So the value will only be plotted at points whenever the gauge happened to be queried, but I might want to record the values at more specific points (like the end of a batch, at intervals in a batch, or on every event).
And it seems convoluted.
Any suggestions?