I have this google sheet with many formulas. The purpose of this sheet to record all Walkins for an institute on daily basis with their relevant status that are FU, DFU or Sales. Example format:
Row no: Col 1 | Col 2 | Col 3 | Col 4 | Col 5
1:Date | Name | Phone | Status | Remarks
2:01/06/15 | Client1 | 1001 | FU | will come again
3:01/06/15 | Client2 | 2002 | DFU | Not joining
4:02/06/15 | Client3 | 3003 | Sales | Enrolled
5:03/06/15 | Client1 | 1001 | Sales | repeat walkin, enrolled today
As soon as Client1 Status set to "Sales", any duplicate entry [which actually checks on Col 3 (Phone)] changes to "Status - Sales" automatically. So Row 2 now becomes:
2:01/06/15 | Client1 | 1001 | Sales | will come again, enrolled 03/06/15
There is another formula calculating the total Sales [=COUNTIF(D:D,"=Sales")] however it is also calculating the duplicate entries. As in above example the total number of Sales should be 1, but it is resulting 2. I tried all possible functions (or atleast upto what I am aware of) but just not getting there.
Any advice without the use of scripts/ macros.
There are some standard formulae for counting distinct values here
If you can use the phone number to identify different clients and it's a genuine number without any other characters, the formula for adding a condition (only count rows containing "Sales" in column D) isn't too complicated:-
=arrayformula(SUM(IF(FREQUENCY(IF(D2:D5=ʺSalesʺ,C2:C5),IF(D2:D5=ʺSalesʺ,C2:C5))>0,1)))
But if you need to use the name it is more complicated - there are some examples here
Related
Not sure if this is the best place to ask about spreadsheets, but here goes:
I'm trying to help someone modify information on one spreadsheet document when information on a separate spreadsheet document is modified (without coding a solution from scratch using the sheetsAPI).
For example, my client has a product database stored in a spreadsheet document, products, when a customer places an order on the clients website, a separate spreadsheet document, openOrders, is updated using the sheetsAPI and some server code. When this document is updated, I'd like to subtract the quantity of items being ordered, from the quantity of the item (or items) available being listed in products. I'm wondering if letting these spreadsheet documents "speak" to each other is possible without coding a solution server-side using the API.
products looks kind of like this:
Product Name | Units | Unit Price
---------------------------------
Product 1 | 6 | 1600
Product 2 | 3 | 1200
Product 3 | 17 | 400
Product 4 | 2 | 600
openOrders looks kind of like this:
Product Ordered | Units | Unit Price | Total
--------------------------------------------
Product 3 | 1 | 400 | 400
Product 2 | 2 | 1200 | 2400
Product 3 | 5 | 400 | 2000
Product 1 | 1 | 1600 | 1600
When the openOrders sheet is updated with a new order, I'd like to subtract the number of Units ordered, from the number of Units available in products. Keep in mind these are two separate spreadsheet documents. I am new to spreadsheets so this is all very foreign to me, it could be possible that I'm using the spreadsheets in a fundamentally incorrect way, and I'm open to that possibility.
you can do:
=ARRAYFORMULA(QUERY({A2:A, B2:B*-1;
IMPORTRANGE("ID_of_spreadsheet", "Sheet1!A2:B")},
"select sum(Col2) where Col1 <> '' group by Col1 label sum(Col2)''", 0)*-1)
I am trying to calculate the cost of products based on the amount of products sold (in one row) and the cost of each item (in another row).
I have written a simple formula, but every time I add or remove columns, it must be manually adjusted.
=IF(COUNT(E4:AC4)>0,(E4*$E$3+F4*$F$3+G4*$G$3+H4*$H$3+I4*$I$3+J4*$J$3+K4*$K$3+L4*$L$3+M4*$M$3+N4*$N$3+O4*$O$3+P4*$P$3+Q4*$Q$3+R4*$R$3+S4*$S$3+T4*$T$3+U4*$U$3+V4*$V$3+W4*$W$3+X4*$X$3+Y4*$Y$3+Z4*$Z$3+AA4*$AA$3+AB4*$AB$3+AC4*$AC$29), "")
This is an example of a problem best solved by ARRAYFORMULA
Take the table
______|_$5_|_$7_|_$2_|_$3_|_$5_|__TOTAL__
-----------------------------------------
Bob | | 2 | | 1 | | ?
-----------------------------------------
Alice | | | 2 | | | ?
-----------------------------------------
Eve | 1 | | 1 | | 3 | ?
How do we solve the total cost for each row?
In the total column for Bob's row (2), simply invoking
=SUM(ARRAYFORMULA(B2:F2*B$1:F$1))
Will accurately give us his total cost; $7*2 + $3*1 = $17.
Specifically, ARRAYFORMULA(B2:F2*B$1:F$1) will give us a range composed of B2*B1 | C2 * C1 | D2 * D1 ..., which you could use e.g. in line below Bob's order to show the price breakdown by item. SUM() adds those numbers together. You could further add to this formula to add taxes, gratuity, shipping, service fees, etc.
Now that we have this formula, we can simply copy this down the column into each new row in the 'Total' column.
When a new column is inserted to the left, the formula will be automatically adjusted by the spreadsheet to be the new range.
I am building a list of gigs I attended and I want to count how many times I've seen each band.
I know about UNIQUE, but because I keep each band in separate column it just copies each row.
Given the table (or screenshot of real data):
| Date | Venue | Bands |
|----------|--------|--------|--------|--------|--------|--------|
| 02.02.17 | Venue1 | Band A | Band B | Band C | Band D | Band E |
| 02.07.17 | Venue3 | Band D | Band C | | | |
The output I want:
| Band | Attended |
| | (times) |
|--------|----------|
| Band A | 1 |
| Band B | 1 |
| Band C | 2 |
| Band D | 2 |
| Band E | 1 |
I can change structure if needed.
What happens after using UNIQUE: https://i.stack.imgur.com/qmszk.png
Thanks in advance.
Step 1. Get list of all unique bands in one column, one per row
=ArrayFormula(UNIQUE(TRANSPOSE(SPLIT(CONCATENATE(Gigs!D2:Z&CHAR(9)); CHAR(9)))))
Step 2. Place this formula in next column, and drag it down
=SUM(COUNTIF(Gigs!D:Z; E2))
Transform your data to a simple table format in order to make easier to do data-analysis.
A simple table use the first row for column headers a.k.a. fields and has one and only one column for each entity, let say only one column for band names.
The above could be done in a single but complex formula hard to debug, so it's better to start by doing this using simple formulas and once you are certain that all is working fine, think about making a complex formula or writing and script.
Related
Unpivot Matrix to Tabular. Using counts of two variables into individual rows
Generate a list of all unique values of a multi-column range and give the values a rating according to how many times they appear in the last X cols
Normalize (reformat) cross-tab data for Tableau without using Excel
How do you create a "reverse pivot" in Google Sheets?
I'm trying to write a SQL query in Google Sheets to try and get data for "matching" results from two different tabs, but running into some trouble.
This is a sheet that's basically an automated scoring engine for instructors who take a two-part test (written and practical). After the results are entered, I'd like to use some SQL to take the results from the two tabs and collate them into a final score.
Link to the sheet in question.
There's a "Practical Scores" tab (which takes all the data from the associated Google Form), and a "Written Scores" tab. I'd like to get the name of the instructors who match in both those tabs, and give the associated score for them, but I'm mostly having trouble with writing the correct SQL.
Most of what I'm trying to do is working fine. I'm able to pull the final practical scores via the following SQL:
=query(PracticalScores!A2:E, "select A, count(E),SUM(E)/3 group by A")
I can also pull the written scores as follows:
=query('Written Scores'!B2:C,"select B,C")
But I want the intersection of the two as well, and that's where I'm running into problems.
=query(A8:E, "select A,C,D where A = E")
will simply return the rows where the names match up, and I want the instances where the names match up, regardless of whether the rows do.
That is, I want all the rows where the names match from tab 1 to tab 2 and not just the few rows that happen to line up perfectly.
If I'm not explaining this well, please let me know and I can provide additional information. Any assistance would be very greatly appreciated!
Since the query function does not support joins, this can't all be done in one query. Instead, the following device can be used:
=arrayformula(vlookup(name column, table, # of column to extract, False))
For example, suppose I have a table
+---+-------+---+
| | A | B |
+---+-------+---+
| 2 | Jim | 3 |
| 3 | Sarah | 4 |
| 4 | Bob | 5 |
+---+-------+---+
to which I want to add another column, taking it from
+---+-------+---+
| | E | F |
+---+-------+---+
| 2 | Sarah | 9 |
| 3 | Bob | 8 |
| 4 | Jim | 7 |
+---+-------+---+
The basic idea is to put in cell C2 the formula
=arrayformula(vlookup(A2:A, E2:F, 2, false))
which will look up every name from first table (column A) in the column E, and return the matching value in column F. Result:
+---+-------+---+---+
| | A | B | C |
+---+-------+---+---+
| 2 | Jim | 3 | 7 |
| 3 | Sarah | 4 | 9 |
| 4 | Bob | 5 | 8 |
+---+-------+---+---+
In practice, one should filter out empty lookup values to improve performance:
=arrayformula(vlookup(filter(A2:A, len(A2:A)), E2:F, 2, false))
If the second table contains some names not present in the first, they will not be returned by the above formula. In this case it is better to prepare a full list of names, for example with
=sort(unique({Sheet1!A2:A; Sheet2!A2:A}))
which collects the names from A columns of two sheets, eliminating duplicates and sorting. Then look up those using vlookup as above.
I have two sheets in a google sheets document. They look something like this:
| Date | Value |
| 2015-01-01 | 100 |
| 2015-02-04 | 200 |
| Date | Value |
| 2015-01-01 | 100 |
| 2015-05-04 | 150 |
The dates and values are NOT regular. I'd like to plot both tables into a single line graph with date along the x axis, and two lines representing the values in each of the tables respectively. I don't want to have to merge the two tables, unless I can merge them automatically with a pivot table or something.
When I insert a chart, I have to choose the column which represents the x axis. In my case, I need the date column from both tables, so effectively two columns to represent my x axis.
A use case for this is simply showing the bank balances for two separate accounts in a line graph.
Thanks.
You can create another table on a new sheet that will merge the data columns from each of these tables, and then have two VlookUp columns, one for each table, and create a graph based on these three columns.
two merge Data columns from two different sheets use this
=FILTER({Sheet1!A:A;Sheet2!A2:A},{Sheet1!A:A;Sheet2!A2:A}<>"")
Your second column will will have the following VlookUp formula
=IFERROR(VLOOKUP(A1,Sheet1!A:B,2,false))
Third Column
=IFERROR(VLOOKUP(A1,Sheet2!A2:B,2,false))
Then just make a graph based on this table that should look something like this
| Date | Value |Value |
| 2015-01-01 | 100 | |
| 2015-02-04 | 200 | |
| 2015-01-01 | | 100 |
| 2015-05-04 | | 150 |