get the total value base on month - excel-2010

i'm trying to get the total of value bas on month like this.
=SUMPRODUCT(MONTH($A$2:$A$10)=MONTH(C2);($B$2:$B$10))
have even try
=SUMPRODUCT(--(TEXT($A$1:$A$10,"yyyy-mm")=C2);$B$1:$B$10)
but all i get is Zero.
here is some sample
Column A b c d f g
2012-10-02 45 2012-10 45 2012 229
2012-09-05 45 2012-09 100 ect.
2012-09-03 55 2012-08 84
2012-08-25 84 ect.
etc.
ect.
thx in advance

with Excel 2010, you have the power of SUMIFS.
I would rewrite the formula as:
=SUMIFS(B:B;A:A;">="&DATE(YEAR(C2),MONTH(C2),1);A:A;"<"&DATE(YEAR(C2),MONTH(C2)+1,1))
which translates to:
Sum column B if the column A value is equal to or greater than the 1st of the month in C2, and less than the 1st of the next month
looking at column F, the same formula for the year would be:
=SUMIFS(B:B;A:A;">="&DATE(E2,1,1);A:A;"<"&DATE(E2+1,1,1))

Try:
=SUMPRODUCT(--(MONTH($A$2:$A$10)=MONTH(C2));($B$2:$B$10))
But be sure that C is a date column (2012-10-xx). Es 2012-10-01.

Related

Google Sheets: lookup a value in a table then find right most non-blank value in a range

I would like to create a google sheet formula that will lookup the ID and return the right-most non-blank score from columns 'Score A', 'Score B' and Score 'D'. Any help would be much appreciated!
ID
Score A
Score B
Score C
Type
2342
65
43
A
8797
B
2343
23
45
98
F
6666
23
B
2333
67
43
B
Assuming E1 is your search_key here's what you can try:
=LET(ζ,TOROW(XLOOKUP(E1,A2:A,B2:D),1),INDEX(ζ,,COUNTA(ζ)))
You may try:
=ifna(lookup(9^9,xlookup(F1,A:A,B:D)))
You can use the following formula. It concatenates for each row the 3 columns into one string and extracts via regex all characters after the last space.
=VLOOKUP(2342,
{
A:A,
ARRAYFORMULA(IFERROR(REGEXEXTRACT(TRIM(B:B&" "&C:C&" "&D:D),"\b(\w+)$")))
},
2)
Just for adding one more option. It won't matter if they're numbers or not, neither if you have empty cells; it will find the non empty cell most to the right
=LET(r,INDEX(2:1000,XMATCH(E1,A2:A)), INDEX (r,,MAX(COLUMN(r)*(r<>""))))

Google Sheets solution

I have a spreadsheet with 3 columns, Column A has values that increment by 10 and column b has the incrementation difference AKA...
Column A
Column B
Column C
125
135
5
135
145
6
145
155
7
Ext... (There are hundreds of rows with these incrementing values)
I also have a value that is placed in an arbitrary place such as "137" we'll call it D1
I need to cycle through the columns some how and find out...
If D1 is => 135 and less than 145 and if so, place the value of column C in another cell AKA(E1).
If D1 is => 135 and less than 145 and if so, place the value of column C in another cell AKA(E1).
Try the following in E1:
=arrayformula(if(isbetween(D1:D,135,145,1,0),C1:C,))
EDIT
i need to cycle through columns A and B and find where my D1 number fits and output the corresponding C value to E1
Try:
=arrayformula(vlookup(D1:D,{A1:A,C1:C},2))

Chossing a row's value based on a dropdown in sheets

I want to choose one of data from column B and column C based on column D to be entered in column E.
A
B
C
D
E
Jan
100
200
B
=Formula to get 100
Feb
101
201
C
=Formula to get 201
March
102
202
C
=Formula to get 202
Apil
103
203
B
=Formula to get 103
Things I will do:
Add data validation in column D so I can change it to dropdown.
Data in column E should change dynamically as D is changed.
Some useful functions I found:
Choose
If
If you have many column then use INDEX/MATCH combinedly-
=INDEX($B$2:$C,ROW()-1,MATCH(D2,$B$1:$C$1,0))
try in row 1:
=INDEX(IF(D1:D="B"; B1:B; C1:C))
I ended up using the following formula:
=CHOOSE(MATCH($D2,$B$1:$C$1,0),$B2,$C2,0)
Thanks to answer by harun24HR.

GETPIVOTDATA in Googlesheets doesn't seem to be working when picking a date column (#REF error)

I am trying to get GETPIVOTDATA to work right while using dates. I have looked at multiple questions here on SO that are for GETPIVOTDATA, but none of them use a date in a reference.
I can create a pivot table with the following data and pull out the total for a given division and subdivision. But I can't crack the code to handling dates right in GoogleSheets version of GETPIVOTDATA, even though my code works in MS Excel.
this data comes from the googledocs supportpage: https://support.google.com/docs/answer/6167538?hl=en
division subdivision product number number of units Date price per unit
east 1 1 14 3/1/2018 $10
east 2 1 15 3/1/2018 $11
west 1 1 11 3/3/2018 $10
west 2 1 21 3/4/2018 $9
east 3 1 16 3/1/2018 $8
west 3 1 18 3/6/2018 $12
east 4 1 11 3/7/2018 $9
east 1 2 10 3/1/2018 $9
east 2 2 9 3/9/2018 $13
west 1 2 12 3/10/2018 $10
west 2 2 15 3/1/2018 $10
east 3 2 12 3/12/2018 $9
west 3 2 16 3/1/2018 $12
east 4 2 12 3/14/2018 $9
The pivot table is anchored into H1 and the columns listed are
division, subdivision, Date, SUM of number of units
in cells H1, I1, J1, K1 respectively
23 =GETPIVOTDATA(K1,H1,"division", "east", "subdivision", 4)
#REF! =GETPIVOTDATA(K1,H1,"division", "east", "subdivision", 4, "Date", datevalue("2018-3-07"))
#REF! =GETPIVOTDATA(K1,H1,"division", "east", "subdivision", 4, "Date", DATE(2018, 3, 7))
It should return "11" which is the intersection of east, 4 and 3/7
The #REF errors return with "Field combination not found in pivot table for function GETPIVOTDATA" even though it seems like all of the fields are listed. As you can see, I can get my summary value if I use two division and subdivision, but not when I add the Date field. I have tried multiple ways to match the datevalue in the pivottable.
I am flustered. What silly thing am I missing here? Please check that your answer actually works in GoogleSheets before suggesting it :)
Thanks!
I know that I'm absurdly late, but this was bothering me as well and I could not figure it out.
I finally realized that the GETPIVOTDATA method uses the total rows, and will throw an error if the correct totals are not there.
Hopefully this helps people who find this like I did.
It turns out that the value argument (technically the pivot_item argument) for the date argument (original_column) must be text that matches the format of the date as it is formatted in the SOURCE of the pivot table, i.e. in the data.
So if the date item is formatted as 3/7/2018 in the original data, then, regardless of how you format the date in the pivot table, a formula that works would be:
=GETPIVOTDATA(K1,H1,"division", "east", "subdivision", 4, "Date", "3/7/2018")
If in the data, there is a subsequent reoccurrence of the same value but is formatted differently, e.g. 3/7 (no year), then as far as I can tell, the first occurrence of that value will be used as the reference format. So the formula above would capture all 3/7/2018 data* assuming the first 3/7/2018 data point is formatted as such.
If another date in the data is formatted as 3/8 Thu (first occurrence), then that's the text that needs to be used in the Pivot Item of the formula.
Google's definition of the Pivot Item is:
pivot_item… - [optional] repeatable
The name of the row or column
shown in the pivot table corresponding to original_column that you
want to retrieve.
It says the name of the row or column. Maybe they were very literal about it, but most likely not, considering this function is borrowed from Excel, and Excel uses the value independent of its format.
*subject to the other pivot columns/items (division & subdivision)
Combining answers from bsoo and Amos47 fixed it for me.
Need to make sure you have "Show Totals" ticked on your pivot table
For dates, don't use datevalue("2018-3-07") - instead use the text function to match the format that you have in the pivot table. This can vary based on the spreadsheet location. For example, if you are referencing a cell A4 you might use =GETPIVOTDATA(K1,H1,"division", "east", "subdivision", 4, "Date", text(A4,"yyyy-mm-dd")).
With dates, I find using either the iso 8601 format "yyyymmdd" or the text version of the month "dd-mmm-yy" helps to avoid errors if it switches between US and European format

Negative References or reversing order of column for DATEDIF

I have a ascending sorted list of irregular dates in Column A:A:
A B C D (A:A,A2:A) E (A:A,A3:A)
2017-11-09 10 10 NA NA
2017-11-10 11 21 1 NA
2017-11-14 15 36 4 5
2017-11-15 22 58 1 5
Column C:C is a rolling sum of B:B. I'm trying to get arrayformula in D:D/E:E to find the datedif between current row (starting date) and X rows above (end date):
=ArrayFormula(DATEDIF(B:B-(X Rows),B:B,"D"))
The goal is to find range of change in D:D over X amount of days:
D:D - D:D-rowX / datedif (A:A-rowX, A:A)
i.e for 2 days on row C4:
(C4-C2) / datedif(C4-2,C4,"D")
(58-21) / datedif(C2,C4,"D")
37 / 5 = 7.4
for 5 days on row C10:
(C10-C5) / datedif(C10-5,C10,"D")
for 15 days on row C20:
(C20-C5) / datedif(C20-15,C20,"D")
I'm trying to calculate X for 1,2,3,4,7,28 rows up which means the array has to start that 1,2,3,4,7,28 rows down.
Right now, the array bugs out to bad reference because the first starting date is DATEDIF(B-X,B1,"D") where B-X is a invalid negative reference. Arrayformulas with bad values instead of bad references seems to just skip past errors and starts working once input are valid. But I can't figure out how to skip bad references. I've tried forcing start date with INDIRECT but can't get it to recognize value as a date. I also tried DATEDIF(B:B, B:B+X,"D"), which spits out the correct numbers but results are offset by X rows. I've tried reverse sorting A:A, =ArrayFormula(if(len(A:A),DATEDIF(SORT(A2:A,1,0),SORT(A:A,1,0),"D"),"")) it produces a reverse orders list of correct answers that I can't figure out how to flip back.
Seems like I'm missing something obvious?
EDIT: tried to clarify original post
Is there a easy way to displace an entire column?
Alternative Solution?
The formula roughly works but is not aligned to the correct row:
C D E
1 2 3
1 2 3
1 2 3
1 2
1
I just need it to display
C D E
1
1 2
1 2 3
1 2 3
1 2 3
To get things aligned, I can put in cell on row2 of Column F:
=array_constrain(ARRAYFORMULA(D:D),COUNT(A:A)-2,1)
Or cell in row3 of Column G:
=array_constrain(ARRAYFORMULA(E:E),COUNT(A:A)-3,1)
But if I try trigger teh formula from row1 via:
=arrayformula(if(row(A:A)>=2,array_constrain(D:D,COUNT(A:A)-2,1)))
It label everythign >=2 row false and still render D:D without displacing the cells the proper number of rows:
C D
1 false
1 2
1 2
1 2
1
EDIT: I'm closing the request, ended up just using vlookup(B:B-X) which provided an approximate enough result to work for my needs.
Short answer
Add the following formula to D1
=ArrayFormula({"N/A";ARRAY_CONSTRAIN(DATEDIF(A:A,A2:A,"D"),COUNT(A:A)-1,1)})
And the following formula to E1
=ArrayFormula({"N/A";"N/A";ARRAY_CONSTRAIN(DATEDIF(A:A,A3:A,"D"),COUNT(A:A)-2,1)})
Explanation
The solution use ARRAY_CONSTRAIN to return just the required result values and use a the array notation to add the required N/A values for the rows that as it don't have a pair to calculate the date difference.
REMARK:
Please note that the DATEDIF functions use the column A for the references as this column is the one that holds the date values.

Resources