I've already seen a lot of topics about my problem, but I can't resolve it.
Actually, I don't understand what is wrong in my formula ?
=ArrayFormula(
IF(
ISBLANK(A6:A);;SUMIFS(
Sheet1!J:J;
Sheet1!K:K; ">="&A6:A;
Sheet1!K:K;"<="& EOMONTH(A6:A;0)
)
)
)
What I'm trying to do :
Each line is a month. I want to SUM all sales made between the first day on the month, and the last one.
If I don't use ArrayFormula, it works. I dont understand how to write this formula to work with ArrayFormula.
Thank you very much for your help !
Just adding this as an answer for you,
Instead of using an array formula, I believe a query would serve you better.
as google date-time syntax is tricky we first have to convert the date value into a text and parse it as "yyyy-mm-dd" we then wrap the EOMONTH to get the last day of the month.
so we use the following formula to get the sum of the months sales:
=query(A:B;"Select sum(B)
where A <= date '"&text(eomonth(E14;0);"yyyy-mm-dd")&"'
AND A >= date '"&text(E14;"yyyy-mm-dd")&"' label sum(B) '' ";0)
hopefully, this is what you were after, apologies for the delay was on the train!
https://docs.google.com/spreadsheets/d/1ygppZZCd4b_Y_HufLwLdcynHAsa3pn6z5YXb3Poc3vk/edit?usp=sharing
Related
I am able to calculate the monthly difference using dateif but not arrayformula
Example : Start Date: 5-Oct-2020
End date: 9-Jun-2021 month difference: using formula (DATEDIF(D3,E3 , "M")).
But I'm unable to use array formula to calculate as I wanted each row to be auto-calculated with dates.
Appreciate some help from Google experts!
Try
=ArrayFormula(IF(LEN(D3:D), DATEDIF(D3:D,E3:E, "M"),))
and see if that works?
References
Arrayformula()
How do arrayformulas work?
I have a Spreadsheet with duration values in one column, and date values in another.
I want to sum duration values based on a particular day of the week... eg, in the example screenshot, the first and last dates are Friday. So I want a formula that would add the duration values from the corresponding cells... a total of 17:00
I've tried a formula like this. But this doesn't work.
=SUMIF(D:D, CHOOSE(WEEKDAY(DATE(),2), "Fri") , A:A)
You could try:
=sumproduct(weekday(A:A)=6,D:D)
try:
=TEXT(ARRAYFORMULA(SUMIF(WEEKDAY(A:A, 11), 5, D:D)), "[h]:mm")
Not sure if there is an easy way because I'm noob at Google Sheets, but try with array formula:
=ArrayFormula(SUMIF(D1:D3;WEEKDAY(A1:A3;2);5))
Using it as array formula, I got this:
Hope this helps
One approach to do this is the following:
In column E put the weekday values. Use WEEKDAY() function which depending on your setting will make Friday any integer between 1-7. If using default Friday will be "6".
Use the SUMIF() function. Eg.=sumif(E:E,"=6",D:D)
Make sure the cell where your SUMIF() formula resides, also has a duration number format.
Please see the data example in the image below...
I would like to sum the amounts separately by months and years.
How can I do this using SUMIF ?
My idea was very simple - to have formula for each month and for each year, like this:
=SUMIF(A1:A100,"2018-01-*",B1:B100)
=SUMIF(A1:A100,"2018-02-*",B1:B100)
=SUMIF(A1:A100,"2018-03-*",B1:B100)
..etc
=SUMIF(A1:A100,"2018-*",B1:B100)
=SUMIF(A1:A100,"2019-*",B1:B100)
..etc
But this formulas don't work. Something is wrong with the criterion.
So what am I doing wrong ? Am I using wildcards incorrectly ?
Example of data that I have
The problem here is that cells containing dates are special and cannot be compared to criterion like 2018-08-*.
The workaround is to use SUMIFS and then set each criterion with the DATE() function. Here is example for 2018-07:
=SUMIFS(B2:B100,A2:A100,">="&DATE(2018,7,1),A2:A100,"<"&DATE(2018,8,1))
You could use Query as in the image below (showing sum for 8th month - August):
By changing month(A)+1=8 you will have different months.
Code:
=QUERY(A1:B5;"select sum(B) where month(A)+1=8 label sum(B) ''";0)
Is that OK for you?
I have a datestamp in this format on A2:
18.11.2015 15:37:13
How can I split this into date and time so that I have date in A3 and time in A4?
I want to do this because datestamp does not sort properly as a number.
I found several answers to this question with various answers but none of them worked for me.
Wouldn't a simple split() be enough ? In B2:
=split(A2, " ")
Alternatively, in B2:
={INT(A2), timevalue(A2)}
Make sure to format col B as DATE and col C as TIME and see if that works?
To get the date and time in those cells you can do the following:
A3: =DATE(MID(A2,7,4),MID(A2,4,2),LEFT(A2,2))
A4: =TIMEVALUE(RIGHT(A2,8))
It's essentially extracting the essential parts for year/month/day from the string in A2 to get the needed order for date. The time is already properly formatted and can be used with Timevalue, we just need to extract the substring.
The date and time values can then be formatted in any way you want them.
I'm trying to get this aggregate date comparison working, and I thought I understood the syntax, but it's clearly not working. Can anyone correct the formula for me?
I'm trying to sum up the amounts in column I, where the date in H is prior to the date in A
My formula is =SUMIF(H$2:H,H$2:H<A4, I$2:I)
Just a small error with your SUMIF syntax:
=SUMIF(H$2:H;"<"&A4;I$2:I)