Count values without having to specify each - google-sheets

I need to count how many times ids repeats, without having to specify each id. In my case I need it for know how many customers come 3 times or more in a month. Here is an example of where Im getting the data from:
customers| id
------------------
person 1 | 2433340
person 2 | 3457548
person 3 | 3457584
person 4 | 4343218
person 4 | 4343218
person 4 | 4343218
person 3 | 3457584
And this one is the one that I need to fill:
Times that customers come
--------------------------
1 time | 2
2 times | 1
3 times | 1

I have used:
Formula in D2:
=QUERY(QUERY(B2:B,"Select Count(B) where B is not null group by B label Count(B) 'Times'"),"Select Col1, count(Col1) group by Col1 label count(Col1) 'Count'")

I would work with a helper column (D) to count visits per person. Then it is pretty easy to count the "x times".
Values in column F are numbers formatted as "0 "time""

Related

How can I count how many times a unique row appeared in my google sheet?

Is there a way to count how many times a unique row appeared in my sheets?
Here's a sample link:
https://docs.google.com/spreadsheets/d/1z036Q4RtfYPyO0JdcJ9Fcb-adundFdzijNG_1ehsT-4/edit?usp=sharing
I need to count how many times "Apple | 10 | 9 | 1" and "Orange | 12 | 10 | 2" appeared.
I tried using this:
={UNIQUE(A2:D8, false), ARRAYFORMULA(COUNTIF(A2:D8, UNIQUE(A2:D8)))}
However, it counts individual unique cells, not the whole row.
See if this helps
=QUERY(Sheet1!A1:D, "Select A, B, C, D, count(D) where A <>'' group by A, B, C, D label count(D) 'Count'", 1)

Use google query as an array formula to sum values in a column based on information in another column

I have 2 tabs needing worked with. The first tab, market_pull has a function that pulls information from EVE Online's ESI and sorts the information into several columns:
duration | is_buy_order | issued | location_id | min_volume | order_id | price | range | type_id | volume_remain | volume_total
The second tab, bulk_market_data sorts the information into several columns:
Citadel ID | Item Id | Item Name | Volume Ea | Qty Available | Lowest Price | Total Volume | Jita Sell | ISK Difference | % Difference
I need help with the bulk_market_data tab. I need to use the Item Id column from bulk_market_data as a criteria to compare to market_pull the column type_id pull the MIN value from the corresponding row in the price column.
I need to do essentially the same thing except I need to use the Item Id column from bulk_market_data as a criteria to compare to market_pull the column type_id pull the total SUM value from the all the corresponding rows in the volume_remain column.
I'm using array formulas because in the bulk_market_data tab there is about 10,000 rows and when I had a formula in every row for every column the sheet slowed down drastically. Thank you for your time and HERE is a sample spreadsheet with the concept.
use in F4:
=ARRAYFORMULA(IFNA(VLOOKUP(C4:C, QUERY({market_pull!C4:C, market_pull!J4:K},
"select Col2,sum(Col3) where Col2 is not null and Col1 = FALSE group by Col2"), 2, 0)))
use in G4:
=ARRAYFORMULA(IF(C4:C="",,IFNA(VLOOKUP(C4:C, SORT(QUERY({market_pull!C4:J},
"select Col8,Col6 where Col1 = FALSE"), 1, 1, 2, 1), 2, 0), 0)))
use in H4:
=ARRAYFORMULA(IF(C4:C="",,ROUNDUP(IF(
E4:E1004*F4:F1004=0,,E4:E1004*F4:F1004), 1)))

Search through Google form data

I have a Google Form that outputs data like this:
Buyers sheet's row example (for each buyer who filled the form):
Timestamp | User 1 | Product 1 | Price 1 | Product 2 | Price 2 | Product 3 | Price 3 ...
Timestamp | User 2 | Product 1 | Price 1 | Product 2 | Price 2 | Product 3 | Price 3 ...
And on another sheet called Bids:
Product 1 | Base Price
Product 2 | Base Price
Product 3 | Base Price
The result I'd like to achieve is getting all the bids for the different products and display next to each product the highest bid with the corresponding username. I've tried with lookupv and query but did not succeed, I'm not exactly an expert in Google Sheets (that's an euphemism).
Any ideas?
Here is an copy of the actual sheet:
https://docs.google.com/spreadsheets/d/1bW_MlogHpXQk-_DZupE22No7KwUyZesqggsEdQaXPgw/edit?usp=sharing
With an example on the Bids sheet for computer of what I'm trying to get.
Buyers is a sheet populated automatically from a Google form.
use:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A, SORT(SPLIT(QUERY(FLATTEN(IF(
FILTER(Buyers!C2:1000, MOD(COLUMN(Buyers!C1:1)-1, 2)=0)<>"",
FILTER(Buyers!C2:1000, MOD(COLUMN(Buyers!C1:1)-1, 2)=0)&"×"&
FILTER(Buyers!C2:1000, MOD(COLUMN(Buyers!C1:1), 2)=0)&"×"&Buyers!B2:B1000, )),
"where Col1 is not null"), "×"), 2, 0), {2, 3}, 0)))

Count unique values for unique dates in Google Sheets

I have a table that contains information on people who volunteered for multiple organizations over a one-month period. One person could have volunteered for the same organization on multiple dates, and multiple people could have volunteered on the same date. I'm interested in tracking, for each organization, unique volunteers (individuals who have volunteered at any point over the course of the month) and unique shifts (for the purposes of this data, a shift is one person volunteering on a unique date).
How can I pull the unique shifts metric? Here's an example of the type of data I'm dealing with:
Organization | Date | Volunteer
A | 10-01-2018 | Jane
A | 10-01-2018 | Ben
A | 10-02-2018 | Jane
B | 10-01-2018 | Emily
B | 10-02-2018 | Jack
You can see that Organization A has 2 unique volunteers and 3 shifts, while Organization B has 2 unique volunteers and 2 shifts. I'm able to get the unique volunteer count by using countuniqueifs with the organization as the criterion, but to get the number of shifts I need both the "Date" and "Volunteer" columns to be unique, while keeping the organization as the criterion.
I'm interested in tracking, for each organization, unique volunteers
=UNIQUE({A2:A, C2:C})
=QUERY(UNIQUE({A2:A, C2:C}),
"select Col1,count(Col2)
where Col1 is not null
group by Col1
label count(Col2)''", 0)
(individuals who have volunteered at any point over the course of the month)
=QUERY(UNIQUE(FILTER({A2:A, C2:C}, MONTH(B2:B)=10)),
"select Col1,count(Col2)
where Col1 is not null
group by Col1
label count(Col2)''", 0)
and unique shifts (for the purposes of this data, a shift is one person volunteering on a unique date)
=QUERY(UNIQUE(FILTER({A2:A, B2:B&C2:C}, MONTH(B2:B)=10)),
"select Col1,count(Col2)
where Col1 is not null
group by Col1
label count(Col2)''", 0)

Query the sum of a product

I want to write a query that returns the sum of two multiplied cells, where the name is equal to a person's name. Let's say I say I have:
| Name | score | days|
|---------|------|------|
| Suzie | 5.0 | 3
| Jonny | 5.0 | 1
| Suzie | 4.0 | 1
| Suzie | 5.0 | 7
| Jonny | 4.0 | 1
basically, I want to know Suzie's average score. Some rows represent multiple days though. The arithmetic would be
(5.0 * 3)
+ (4.0 * 1)
+ (5.0 * 7)
I want to write a query:
=(index(query({a1:c3}, "Select Sum(Col2 * Col3) where Col1 = '" & D22 & "'"),2))
However, it doesn't like the part that says "Sum(Col2 * Col3)"
Is it possible to do the sum of two columns multiplied?
Thank you in advance!
Please see this sample file.
Data
Col1 Col2 Col3
a 10 20
a 30 40
b 10 30
Result
a 1400
b 300
Formula
=QUERY({A2:A,ARRAYFORMULA(B2:B*C2:C)},
"select Col1, sum(Col2) where Col1 <> '' group by Col1")
You don't need a query.
sum of two multiplied cells, where the name is equal to a person's name
Use SUMPRODUCT(array1, [array2, ...]):
=SUMPRODUCT(B1:B5,C1:C5,A1:A5=D22)
Notice that A1:A5=D22 is a criterion.
average score
Use SUMIF(range, criterion, [sum_range]):
=SUMPRODUCT(B1:B5,C1:C5,A1:A5=D22)/SUMIF(A1:A5,D22,C1:C5)

Resources