How to create column and lines charts from this simple spreadsheet? - google-sheets

I'm trying to create two charts from a local cycling club's account spreadsheet. These will provide "at-a-glance" overviews of the state of the current finances.
The spreadsheet has a columns with incoming monies (receipts) and the date received, with similar columns for outgoing money (payments).
The first chart will sum up the incoming outgoing columns and display these in a simple column chart. A quick glance should show that the incoming column is taller than the outgoing (hopefully!). This is where I hit my first problem - I don't seem to be able to use SUM in the chart:
I have ended up having to reference a cell containing the sum of the column, but this sum takes into account a cell (C3) which contains balance brought forward from a previous year which I want to ignore for this chart:
The other chart I want is a line chart showing amount of money on the y-axis and time on the x-axis. The receipts line should go up over the year (again, hopefully) and the payments should go down. I'm not even close to getting this correct:
It should be something like this, so as the year passes (x-axis) the amount (y-axis) of receipts and payments increases:
How can I create these charts?
Spreadsheet is here - https://docs.google.com/spreadsheets/d/1-8DzB6c3rZ8evfNJ8iRcO_2BletbH81FV4hIis0-Fj4/edit?usp=sharing

I tried to replicate your graph and found some issues:
On the first graph, you cannot use formula in Data Range. The input should only be a A1 notation. Creating another entry on B16:C17 and use it as graph data is correct.
If you want to ignore C3, just change the formula in your C16 with =SUM(C4:C8)
Based on the sketch you've provided for the second graph, The data will only go up by getting running total or cumulative sum of each data per category (Receipts, Payments). Unfortunately, Google Sheet does not have built it function that can automatically do that. You have to create another column for cumulative sum.
Example:
For Receipts, insert this in D4:
=ArrayFormula(If(len(C4:C8),(SUMIF(ROW(C4:C8),"<="&ROW(C4:C8),C4:C8)),))
It will create another column with cumulative sum of C4:C8.
For Payments, insert this in H3:
=ArrayFormula(If(len(G3:G7),(SUMIF(ROW(G3:G7),"<="&ROW(G3:G7),G3:G7)),))
The dates from Receipts and Payments are different, if you only use the dates of Receipt, the data for Payments will be inaccurate. You need to create another table that will combine the dates and data of those two categories.
Try this:
J2: ={A4:A8;E3:E8}
K2: =ARRAYFORMULA(IFERROR(VLOOKUP(J2:J11, A4:D8, 4, false)))
L2: =ARRAYFORMULA(IFERROR(VLOOKUP(J2:J11, E3:H7, 4, false)))
Make sure to add Labels on K1 and L1.
It should look like this:
Once you have the data, just highlight J1:L11 and Go to Insert -> Chart -> Convert it to Smooth line chart -> Check Aggregate
The graph should look like this:
References:
VLOOKUP
ARRAYFORMULA

Related

Multiple Criteria - vlookup

I have been trying to use an If(and... to grab a lookup if the weight (column F) meets the range on a second sheet between the min and max columns.
For example: If a SKU's weight is between a highsize and a low size on sheet 2 and the helper column matches, then I'd like to pull in the price.
Link: https://docs.google.com/spreadsheets/d/1ermKIQnZRcWzm8ogDE7IK0fQSLohDsOBHuaUjjRi8io/edit?usp=sharing
The helper column is a join of the shape, color, and clarity, however, the carat weight will then decide what the standard industry price for that goes.
Multiple SKUs can have the same shape, color, and clarity so the weight would be the defining factor. I created helper columns to help with that part, however, I am having trouble getting a formula that would combine a lookup and an if weight is >highsize and <lowsize.
The main project I'm working on has many, many, skus so going through each one and copying is not a viable solution. The second part is that the second sheet's prices will update on a weekly basis so I need to be able to update it to populate on the first sheet.
try in P1 cell:
={"E-Price"; INDEX(IFNA(VLOOKUP(B2:B, 'e-Price Ranges'!A2:G, 7, 0)))}

Google Sheets vectorized operations

I have a Google sheet with a column of dates and numbers. What I want to be able to do is say: If the date is earlier than 9/1/2021, take the number and multiply by 1, otherwise multiply by 2, then sum all the products. The date and number columns keep getting new information as time goes on.
Now I know that I could create a kind of "scratch-work" column where I have a cell containing =IF(DATEVALUE(A1)<DATEVALUE("2021-9-1"),1,2) * B1 and then apply this formula to the column, and then sum the column somewhere else. However, this is not ideal because every time a new date and number come in I have to reapply the formula to the new scratch-work column's cell.
What I was hoping for was some kind of vectorized operator that would eliminate the need for the scratch work column in the first place. Something like being able to multiply whole columns like =B1:B * 2 or what is more appropriate for my current task, =IF(DATEVALUE(A1:A)<DATEVALUE("2021-9-1"),1,2) * B1:B.
I know you can do this kind of thing in R but haven't seen any vectorized operations in Google Sheets. I'm guessing it's not possible but wanted to ask just in case.
=arrayformula(if(A1:A="","",IF(DATEVALUE(A1:A)<DATEVALUE("2021-9-1"),1,2) * B1:B))

Setting formula range from first to last populated cell in a column?

For a league I run we keep track of games played and w/l/t and calculate that into a ranking score. The player name is listed in column U and the ranking score in column AD of a fixed table. I then use an array formula to list the players in ranking order in column E (then vlookup to pull in other stats based on the value in E for that row). Specifically I use this formula in column E:
=ARRAY_CONSTRAIN(ARRAYFORMULA(INDEX($U$4:$U$153,MATCH(LARGE($AD$4:$AD$153-ROW($AD$4:$AD$153)/COUNT($AD$4:$AD$153),ROW(E72)-ROW(E$4)+1),$AD$4:$AD$153-ROW($AD$4:$AD$153)/COUNT($AD$4:$AD$153),0))), 1, 1)
I need to be able to add players to the table in U:AD without having to edit the formula every time, i.e. from $U4:$U153 and $AD$4:$AD$153 to $U4:$U154 and $AD$4:$AD$154 in all the various places in the formula then copy the new formula all the way down.
Is there a way that I could define the range as $U$4:$U(last populated row) and the same for column AD in the above formula?
I eventually be using this in both Excel and Google Sheets so I would really like to avoid scripting. First I'm looking to solve this for Google Sheets.
Here is a copy of the sheet I am working on.
You could use INDEX and COUNTA
Instead of $U4$U153,
$U4:INDEX(U4:U,COUNTA(A4:A))
The COUNTA portion will give the number of populated rows and feed it into INDEX to give $U4:$U153
The answer for the Google sheet that you shared.
skip to the end for the simple solution
I used the indirect method by entering a formula in E1 that counts the AD column for player stats and adds 3 to get the last row. (I was going create the full range AD4:AD?? but you also have U4:U73 in the formula)
=counta(AD4:AD)+3
I then changed your formula use indirect, indirect("$AD$4:AD"&E$1), to reference the last row number in cell E1 to create the required range.
=iferror(ARRAY_CONSTRAIN(ARRAYFORMULA(INDEX(indirect("$U$4:U"&E$1),MATCH(LARGE(indirect("$AD$4:AD"&E$1)-ROW(indirect("$AD$4:AD"&E$1))/COUNT(indirect("$AD$4:$AD"&E$1)),ROW(E4)-ROW(E$4)+1),indirect("$AD$4:$AD"&E$1)-ROW(indirect("$AD$4:$AD"&E$1))/COUNT(indirect("$AD$4:AD"&E$1)),0))), 1, 1),"")
I discovered by accident that if you remove the ARRAY_CONSTRAIN from your formula and change U4:U73 to U4:AC73 then the formula will populate the scores to the right of your formula where you currently have vlookups. I put an example of this in E4 but note that you will have to delete the vlookup formulas if you want to fill the formula down otherwise it will show REF
I also added iferror so that the formula can be copied to the same row as the end of the "open slots" in column A without showing errors.
Also, I got to this point and was thinking that since you're using Google Sheets, a better way to do this could be to use the QUERY function to pull the data and also sort it using ORDER BY with a single formula in cell E4.
I've not really used the QUERY function but maybe it's time to learn.
EDIT
Turns out it doesn't take much learning
=QUERY(U4:AD,"SELECT U,V,W,X,Y,Z,AA,AB,AC ORDER BY AD DESC")
Put the formula above in cell E4 and delete everything beneath and scores to the right and you're done. you'll notice that there is no indirect because Google understands that you don't want the blank rows.
https://docs.google.com/spreadsheets/d/16IclEmKwDFdInIAZhH2vt-tLJ5pbwX06jv9xrUXwhnY/edit?usp=sharing
Why are you using $ signs around U4:U153,remove $ signs for rows that will give you flexibility while keeping columns fixed.As your drag the formula,the data array will append the newly filled cells or you can create table using Ctrl+T that will automatically expand as you keeping adding data.

SUMIFS function across multiple sheets

For reference, please visit this Google Doc which is a simplified example of my problem, which is to determine total sales in Blue and Green markets each month.
Each month, I receive a new sales report from accounting for all of our markets and I add the sheet to the main workbook. My team is in charge of assigning "colors" to the markets and tracking this. As it's privileged information, we can't have accounting auto-tag these in the data they send over.
One solution would be, for each new monthly report that comes in, tag each city with the color. However, we have hundreds of markets and this isn't very practical to go through each time.
I assume that a SUMIFS function would work here, but am unsure how to set it up when there are values spread across multiple sheets.
You can use this function in B8 of February tab:
=SUM(IF(COUNTIFS($A$2:$A$5,Color!$A$2:$A$5,Color!$B$2:$B$5,'Sales February'!A8)>0,$B$2:$B$5,0))
COUNTIFS($A$2:$A$5,Color!$A$2:$A$5,Color!$B$2:$B$5,'Sales February'!A8)>0 gets an array of the countries that belong to the colour specified in A8 of the current tab (Would that be possible to put only Green and remove February Sales from that cell?).
If the country belongs to the particular colour, then return the array of corresponding values in column $B$2:$B$5.
Lastly, sum this array.
Note:
You need to array enter this formula in Excel (by holding Ctrl+Shift then hit Enter after typing in the formula).
In Google Spreadsheets, you array enter a formula by wrapping the formula around =ArrayFormula(), meaning you use:
=ArrayFormula(SUM(IF(COUNTIFS($A$2:$A$5,Color!$A$2:$A$5,Color!$B$2:$B$5,'Sales February'!A8)>0,$B$2:$B$5,0)))
In Excel you can use this "array formula"
=SUM(SUMIF(A$2:A$5,IF(Color!B$2:B$5=A8,Color!A$2:A$5),B$2:B$5))
confirmed with CTRL+SHIFT+ENTER
The same formula works in google docs if wrapped in arrayformula, i.e.
=arrayformula(SUM(SUMIF(A$2:A$5,IF(Color!B$2:B$5=A8,Color!A$2:A$5),B$2:B$5)))
or you can use FILTER as user3465711 suggests, i.e.
=SUM(filter(B$2:B$5,isnumber(match(A$2:A$5,IF(Color!B$2:B$5=A8,Color!A$2:A$5),0))))

How to go from individual date/time log to "timeline" graph?

I have essentially a log file in a Google Sheets. Columns are "Date/time", "user", "asset accessed", and there will be multiple entries for the same date, though usually not time.
I'd like to use the timeline graph to show user activity, but the graph requires an aggregate view with one date (no time) per row, with a numeric count in second col. Is there a way using functions within Google Sheets to generate an aggregate "view" of this data and pass this to the timeline graph?
Well, I guess you'll have to create an auxiliary sheet, or just some columns with the summarized values for you chart.
From your description, I'll assume you're using 3 columns (ABC). Let's use columns D, E and F with the following formulas:
=ArrayFormula(Trunc(A:A))
=Unique(D:D)
=ArrayFormula(CountIf(D:D;E:E))
Since date values are actually a number (qtt of days since the epoch), and hours are decimals, the Trunc formula gets rid of the "time" part and leaves only the date. Just format the cells (apparently numbers) as dates and you'll see. Then Unique and CountIf do the summarizing.
There's surely different ways of doing this, perhaps more "elegantly", in a single formula. But I think that in this way it's more easy to understand and learn from. Also, you'll probably need to adapt the ranges to your actual columns positions (I hope that's not a problem).

Resources