Add zero in number in Google Sheets formula - google-sheets

I am looking for a formula in Google Sheets to find the number of the week of a date. The desired result would be a concatenation of S + the number of the week (with a space between the two). If the number of the week is less than 10, I would like an extra 0 in this data.
Here are the different results desired according to the different cases:
01/01/2023 → S 52
02/01/2023 → S 01
27/08/2023 → S 09
After many attempts, I still cannot incorporate the 0 when the week number is less than 10. Could you please help me?
Here is my formula (assuming a date is in A1):
="S "&(SI(NO.SEMAINE(A1)-1<10);"0"&NO.SEMAINE(A1)-1;NO.SEMAINE(A1)-1)

Can you try:
="S "&TEXT(WEEKNUM(A1;21);"00")

Use TEXT() function. Try-
="S + " & TEXT(WEEKNUM(A1);"00")

Related

Why can't my Google Sheets Query recognize formula results as numbers?

So I have a formula one one sheet that calculates the difference between the current date (Using the today function) that corresponds to when a repair was requested - this column gives me how many days have passed since the request was made. In a separate sheet, I want to query the requests that are beyond 14 days old but less than 22 days. I write the query as:
Select A,B,C,D,G Where J>14 and J<22
but the cell just displays "N/A". But if I rewrite the code with single quotes on the 14 and 22 as:
Select A,B,C,D,G Where J>'14' and J<'22'
It returns repair requests that are two days old. This tells me that it recognizes the formula results as Strings even if I already set the format to Number.
Can anyone help?
To anyone wondering, I was able to fix this issue by using the VALUE() function (which works for both Google Sheets and MS Excel) which converts any string to numbers.
if J column are dates try:
=INDEX(QUERY({A:G, DAY(J:J)}
"select Col1,Col2,Col3,Col4,Col7
where Col8 > 14
and Col8 < 22")

Sum products in certain conditions

I'm sorry to ask this, I have not any code skills and I've trying to figure that out for a few hours now.. I think an image will be better for you to understand what I want:
I want A2 to show the sum of the products in G:G that fit certain conditions (2020,jan,buy). I haved tried several formulas but I came up with this one as the closest, I think, but still won't work:
=arrayformula(SUMIFS(E:E=B1,F:F="jan",G:G="buy",H:H))
Can anyone explain me how to achieve that?
Thanks very much :)
Please use this formula in A2 it will work
=sumifs(G2:G100,D2:D100,2020,E2:E100,"jan",F2:F100,"buy")
So basically, sumifs formula is right one as you want to check for multiple conditions.
so this is how this formula work
=sumifs(sum_range,criteria_range1,criteria1,criteria_range2,criteria2,...)
In your case your same range is column 'G' so if you have a finite range like only 25 rows you have in your table then instead of G2:G100 you can use G2:G25 as G1 is containing label and make sure that all other ranges also similar to the range of column G. for example if you take range of G2:G100 means 99 rows then you should take E2:E100 or E3:E101(range of 99 rows, that rows must be 99 and series start and end number is as per your requirement, similar case for other columns in this formula)
you have to check 2020 in column D, so you criteria_range1 is of D column I took it D2:D100 and criteria 1 is 2020 as it's a number it doesn't need double quotes
criteria 2 is you need to check Jan in column E so criteria_range2 is column E I took it E2:E100 and criteria 2 is "jan" as it's not a number so I took it in double quotes.
criteria 3 is you need to check 'buy' in column F so Criteria_range3 is column F. I took it as F2:F100 and criteria 3 is "buy" again it's not a number so took it under double quotes.

Sum entries per date when multiple entries of date exist

I have 1 column of dates and 1 column of 'wins' recording 1 and -1 as wins and losses. I need a quick way to tally the score across each date (so I can graph the win-rates). Eg. 5th May 7 wins, 6th may -2 wins, etc. I have multiple entries for each date and several days to work through so I can't do it manually. What would be the simplest approach/formula to solve this issue?
I'm working in Google Sheets. If someone has a simple workaround in Excel too, the solution is welcome.
Try:
=SUMPRODUCT(($A$2:$A$12=$E$1)*($B$2:$B$12)) in cell E6
Data structure:
=QUERY(A1:B, "select A,sum(B)
where A is not null
group by A
label sum(B)''")

Repeating time windows in Google Spreadsheets?

I'd like to insert time windows repeatedly in a column, like this:
10:00-10:20
10:20-10:40
10:40-11:00
11:00-11:20
11:20-11:40
12:00-12:20
Is there a way to achieve this?
Put data in cells:
B1 = 10:00 (start time)
B2 = 12:20 (end time)
B3 = 20 (interval in minutes)
Here's single arrayFormula, that will generate your column:
=ARRAYFORMULA(TEXT(B1+B3*1/24/60*(row(OFFSET(B8,,,(B2-B1)/(B3*1/24/60)))-row(B7)-1),"HH:MM")&"-"&TEXT(B1+B3*1/24/60*(row(OFFSET(B8,,,(B2-B1)/(B3*1/24/60)))-row(B7)),"HH:MM"))
Explanations
Look at sample file to explore more about this formula. Pay attention on some details:
any kind of logical sequence could be done with help of series 1,2,3... Formula like =ARRAYFORMULA(row(OFFSET(B8,,,7))-row(B7)) gives us column from 1 to 7.
Time treated like numbers in sheets: 1 day is 1, 1 hour is 1/24, 1 minute is 1/24/60 and so on
Time can't be properly converted into text as it's number. So you have to use text(time, "HH:MM") formula to convert time into text.
This will repeat your time window. The formula assumes the time range is in A2:A6.
The 3 in the formula is the number of repeats (change to you need). You might want
to consider placing A2:A6 on another sheet and referencing it in the formula.
=TRANSPOSE(SPLIT(JOIN(",", ARRAYFORMULA(SPLIT(transpose(rept(join(",",A2:A6)&",",3)),",")&",")), ","))

Trouble combining Google Spreadsheet time calculation with isblank function

I'm currently using a Google Spreadsheet at work to track employee hours. I had been using a formula to calculate hours, with hours worked expressed as a time (e.g. 6 and a half hours shows as 6:30). My boss has asked that I change the hours worked total to numbers (e.g. 6.5 instead of 6:30).
I had been using the following formula to calculate hours worked in time (where B is the out time and A is the in-time):
=if(isblank(B1),"", MINUS (B1,A1))
For calculating hours worked expressed in numbers, I have been trying to use the following formula:
=(IF(A1 <= B1, 0, 1)+B1 - A1) * 24
Now, this formula works when inputted into C1, but I'd like C1 to read as blank ("") until a value is inputted into B1, because otherwise it will show a value once I put something into A1.
Can anyone lend some insight?
You should be able to check that there are three values with COUNT(A1:C1).
=if(COUNT(A1:C1)<3, "", (IF(C1 <= B1, 0, 1)+B1 - A1) * 24)

Resources