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)''")
Related
I can't figure out how to solve my issue in google spreadsheet.
I have a column with some packages we want to release on our website on specific random dates. Not all fields in these column are populated, some are empty. For the populated ones I want to assign a random number between a range (A,B) which I take from other fields and have a max number of duplicates (the number of duplicates I take from another field).
For example I have 60 packages and I need to assign them between 1 and 31 (days of current month) so that means I will have 2 duplicates/day and I will put my duplicate field value to 2. But these 60 packages are shown in 80 rows for example, 20 rows empty, so those must not have any number assigned to them.
I have tried a few solutions with RANDBETWEEN and SORT etc but I did not manage to make it work. Now I switched to writing a custom function but I have never written one in google app scripts before, so if any of you guys have experience with this I would highly appreciate.
Random dates
Use this formula to get random dates between start date and end date appended randomly and duplicated only twice.
=ArrayFormula(IF(A2:A="",,
VLOOKUP(A2:A,
{SORT({ FILTER(A2:A,A2:A<>""),
RANDARRAY(COUNTA( FILTER(A2:A,A2:A<>"")),1) },2,1),
TRANSPOSE(SPLIT(REPT(TEXTJOIN(";",1,($E$1+SEQUENCE(DATEDIF($E$1,$E$2,"D"),1,1)))&";",$E$5),";"))},3,0)))
Sort chronologically
01 - paste in G2.
=SORT(QUERY(UNIQUE(QUERY({B2:B},"Select * where Col1 is not null ")), "where Col1 is not null"),1,1)
02 - paste this formula in H2 and drag down.
=IF(G2="",,TEXTJOIN(", ",1,FILTER($A$2:$A,$B$2:$B=G2)))
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.
The "mirror" sheet contains data.
Column B of the "bonus" sheet calculates the number of projects in a given month in which the specialist is involved.
=COUNTA(query(mirror!$A$2:$B, "select B where
A <= date'"&TEXT(EOMONTH($A6,0),"yyyy-mm-dd")&"'
and
A >= date'"&TEXT($A6,"yyyy-mm-dd")&"'
ORDER BY B"))
On the "mirror" there are no projects for Dec 2020 and Jan 2021.
The counts function substitutes 1 for the "bonus" in these months, although 0 is expected.
I've already broken my head, I don't know how to overcome it. I would be grateful for ideas.
Upd. Column A of the "bonus" sheet contains dates in the form of 8/1/2020, 9/1/2020, 10/1/2020, etc. beginning of the month.
In column A of the "mirror" sheet, the dates can be 10/5/2020, 10/31/2020, i.e. not necessarily the end of the month.
COUNTA counts an error as 1 (because it is "a non-null something"). So if your QUERY finds nothing, it will return an error — which will be counted as "one thing."
Try wrapping your QUERY in IFERROR, inside your COUNTA:
=COUNTA(IFERROR(QUERY(...)))
You can use SUMPRODUCT:
=SUMPRODUCT((MONTH(mirror!$A$2:$A)=MONTH(A2))*(YEAR(mirror!$A$2:$A)=YEAR(A2)))
So basically I need a dynamic select statement which changes references when dragged across rows or columns.
Example of what I need.
=sum(query('Sheet1'!$A$1:$F$621, Indirect("Select"&$F&"Where A='ABC' AND B="&"Sheet2!"&$A1)))/20
Sample Sheet 1 (Data Sheet)..--Since I am not allowed to use images till i reach rep 10 lol :)
Column 1 - Sales Sites (ABC, DEF, GHI.....)
Column 2 - Sales Roles (SM, ASM, SE.....)
Column 3 - Sales in Month Jan
Column 4 - Sales in Month Feb
Column 5 - Sales in Month Mar
Sample Sheet 2 (Desired Output)
Description (in pivot terms):
Site wise (filter)
Role wise (Rows)
Month wise (Columns - Sum of Jan, Feb etc)
Value (Sum of Jan/20)--To get day wise sales numbers
FYI:
I have tried using pivots, but google spreadsheets don't allow use of calculated fields in pivots in any manner (for the /20 in the formula), hence trying to achieve the same results by formula.
I know a table on the basis of the pivot table could help solve this problem, but to make it more efficient I am trying to avoid using 2 tables.
Many Thanks for your help in advance, please let me know if you need additional info to understand the scenario.
Thank you ahead of time for anyone who can help me with this, I think I am close, but it still isn't working.
I have a simple sheet activity reporting sheet that I am asking staff to complete over the upcoming year - It has 5 columns:
Column A: Date -In format (4/4/2013 13:30:00)
Column B: Title -In format (text string)
Column C: Attendance -In format (Numbers)V
Column D: Vol led - In format (text string)
Column E: Staff Led - In format (text string)
Using this data I am 90 % positive that I can aggregate on a different summary sheet that contains some static data like months (in the B column) to aggregate on. I am having trouble configuring the criteria in the filters though to cause the correct output to either sum or count .
Quantity of events ed by either staff or vol, if neither box is checked the event should not be counted) Right now I am trying this but it is not working
=SUM(FILTER('Hostel Activities'!A:A,MONTH('Hostel Activities'!A:A)=$B3, NOT(AND(ISBLANK('Hostel Activities'!D:D),ISBLANK('Hostel Activities'!E:E)))
Total number of attendance in a month for activities led by staff or volunteers Right now I am trying this but it is not working
=SUM(FILTER('Hostel Activities'!A:A,MONTH('Hostel Activities'!A:A)=$B3, NOT(AND(ISBLANK('Hostel Activities'!D:D),ISBLANK('Hostel Activities'!E:E)))
THIE WORKS! ## Heading ##Total number of volunteer led activities in a month for activities Right now I am using this and it IS working
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,not(isblank('Hostel Activities'!E:E))))
Thank you for any assistance and/or guidance
Danny
The first problem I see with your first two formulas is that you're calling SUM on your FILTER result. But the FILTER is returning the column A, which are dates. So, your basically summing dates, which will surely not yield the result you're looking for. Why are you not using COUNT, as you did on your last formula?
Second, the first two formulas you pasted are identical, how do you expect them to return different results?
It seems that for the first two want to sum an OR condition. You can do this two ways (that I can think of now). The simpler to understand is just to sum two COUNT(FILTER(... formulas, one for each criteria, e.g.
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,not(isblank('Hostel Activities'!D:D)))) + B6
Assuming that on B6 is the other COUNT formula (the 3rd one, that already works).
Another option would be to use an OR function as criteria for the FILTER. Like this:
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3, OR(NOT(ISBLANK('Hostel Activities'!E:E)), NOT(ISBLANK('Hostel Activities1!D:D))) ))
I believe I have figured out a method that works by making some adjustments in the formulas and the source data.
Basically
IN THE SOURCE REPORTING DATA:
I combined columns D and E into the same column and added data validation so the coordinator has to enter if the activity is led by staff,volunteer, or neither.
IN THE MONTHLY AGGREGATION REPORT:
To count the number of activities led by either staff or volunteers I used this :
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Staff"))+E3
*E3 is the count of volunteer led activities which is found using this formula:
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Volunteer"))
Adding up the number of participants in activities run by either staff or volunteers was a little more difficult, but I was able to do it by adding up 2 unique equations. I would prefer using an OR statement in the filter criteria, but I just couldn't get that to work. This is how I was able to make it happen:
=SUM(FILTER('Hostel Activities'!C:C,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Staff")) + SUM(FILTER('Hostel Activities'!C:C,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Volunteer"))
Thank you all for your assistance