Googlesheet Query Row Values in a Colunn by specific values in another - google-sheets-formula

Sheet contains table and 9 query problem set.
https://docs.google.com/spreadsheets/d/1-YW7prEz2rkCKangks2CeDK2spCidGQa8hJJhXWmGiI/edit?usp=sharing
Trying to solve for each customer request:
1 For Mike, into one cell, list Title and Rating for Title that is specifically "Where is the Sun?" List only those with Rental Date that is not TODAY(), which is 9/1/2022
2 For Lizzy, into one cell with results sorted by latest Rental Date, find all Rental Dates, Ratings, and Elements, specifically by her Favorite Title: Where is the Venus?
3 For Ed, his favorite element is specifically "A", query Rental Date, Source, Title, into one Cell AND/OR bring back Rental Date, Source, Title for rating that is exactly 10.00%
4 For John, find Source, Title, Rating into one cell, sorted by oldest Rental Date, that contain "A" in element but those elements can never contain "K"
5 For Mona, find the Rental Date, Title, and Elements for the lowest rating. In another cell, do the same but find for the highest rating.
6 For Claire, find the Title, Rental Date, and Elements for highest rated title that is "Where is Venus"
7 For Frank, find the Title, Rental Date, and Elements whose Rating is closest to the Average Rating. In another cell, do the same for the the Rating that is farthest from the Average Rating.
8 For Jack, find the Rental Date and Title whose Rating is the biggest outlier in the range of Rating?
9 For Mina, list all Titles that have duplicate Rental Dates, Group titles and state their duplicate duplate Rental Dates.

your A2 cell is 9/1/2002 not 9/1/2022 (TODAY)
1:
=ARRAYFORMULA(TRIM(QUERY(CHAR(10)&FLATTEN(QUERY(TRANSPOSE(QUERY(A:E, "select C,D where C='Where is the Sun?' and A < date '"&TEXT(TODAY(), "e-m-d")&"'", 0)),,9^9)),,9^9)))
2:
=ARRAYFORMULA(TRIM(QUERY(CHAR(10)&FLATTEN(QUERY(TRANSPOSE(QUERY(A:E, "select A,D,E where C='Where is Venus?' order by A desc", 0)),,9^9)),,9^9)))
3:
=ARRAYFORMULA(TRIM(QUERY(CHAR(10)&FLATTEN(QUERY(TRANSPOSE(QUERY(A:E, "select A,B,C where E matches '.*(A,|, ?A$).*' and D = 0.1", 0)),,9^9)),,9^9)))
4:
=ARRAYFORMULA(TRIM(QUERY(CHAR(10)&FLATTEN(QUERY(TRANSPOSE(QUERY(A:E, "select B,C,D where E matches '.*(A,|, ?A$).*' and not E matches '.*(K,|, ?K$).*' order by A desc", 0)),,9^9)),,9^9)))
5:
=ARRAYFORMULA(TRIM({QUERY(CHAR(10)&FLATTEN(QUERY(TRANSPOSE(QUERY(A:E, "select A,C,E where D ="&MIN(D2:D), 0)),,9^9)),,9^9), QUERY(CHAR(10)&FLATTEN(QUERY(TRANSPOSE(QUERY(A:E, "select A,C,E where D ="&MAX(D2:D), 0)),,9^9)),,9^9)}))
6:
=ARRAYFORMULA(TRIM(QUERY(CHAR(10)&FLATTEN(QUERY(TRANSPOSE(QUERY(A:E, "select C,A,E where C = 'Where is Venus?' order by D desc limit 1", 0)),,9^9)),,9^9)))
7:
=ARRAYFORMULA(TRIM({QUERY(CHAR(10)&FLATTEN(QUERY(TRANSPOSE(QUERY({A2:E, ABS(D2:D-AVERAGE(D2:D))&""}, "select Col3,Col1,Col5 where Col6 ='"&MIN(ABS(D2:D-AVERAGE(D2:D)))&"'", 0)),,9^9)),,9^9), QUERY(CHAR(10)&FLATTEN(QUERY(TRANSPOSE(QUERY({A2:E, ABS(D2:D-AVERAGE(D2:D))&""}, "select Col3,Col1,Col5 where Col6 ='"&MAX(ABS(D2:D-AVERAGE(D2:D)))&"'", 0)),,9^9)),,9^9)}))
8:
no idea what "biggest outlier in the range of Rating" is. if you want that negative value just say so...
9:
kindly provide an example of the desired result in your sample sheet

Related

Filter data according to a selected value, sorting and counted by date in Google Sheets

In the first column I have a list sorted by the date of several students and its topics requested. As can be seen, the table is arranged by data, name, topic and a checkbox if the question has been solved.
In the second column, I have a drop down list where I want to select the student and query below his last 15 days requests, checking whether it is completed or not.
Every time the student is selected, the row A4 will display all his/her topics sorted from the latest 15 days, and the cells F3 and F4 will count according to total and solveds.
Is that possible to apply it via formula?
Here is the file if you need:
https://docs.google.com/spreadsheets/d/1w7beVyUr0pEUoRSgqQYYOi0y0Sbd8scC3B825GKA3sQ/edit?usp=sharing
your column A on Control sheet contains a mixture of dates and text strings (invalid dates) so the formula needs to be:
=ARRAYFORMULA(QUERY(SORT({IFNA(IF(N(Control!A2:A)<>0; Control!A2:A; DATE(
REGEXEXTRACT(Control!A2:A; "/(\d+) ");
REGEXEXTRACT(Control!A2:A; "/(\d+)/");
REGEXEXTRACT(Control!A2:A; "^\d+"))+
INDEX(SPLIT(Control!A2:A; " ");;2)))\ Control!B2:D}; 1; 0);
"select Col2,Col3,Col4 where Col2 = '"&A1&"' limit 15"; 0))
F3:
=COUNTA(B4:B)
F4:
=COUNTIF(C4:C; TRUE)

Sort data in google spreadsheet

I have a google form linked to a google sheet. The google form let me choose a date and select names. These persons are clients of a meeting at this date.
The google form gives me a date in the 1st column and a list of names separated by commas in the 2nd column. Eg
8.15.2020 John, Mike, Eva
8.20.2020 John, Eva, Gudrun, Pete
Now I want to sort this tab by names - 1st column list of names, 1st row list of meeting dates, an 'x' where the person joined the meetiing and save it in a new tab. Eg
8.15.2020 8.20.2020
John x x
Mike x
Eva x x
Gudrun x
Pete x
How can I solve this problem?
try:
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(
IF(IFERROR(SPLIT(Sheet1!B1:B; ", "))="";;
Sheet1!A1:A&"♦"&SPLIT(Sheet1!B1:B; ", "))); "♦");
"select Col2,count(Col2)
where Col2 is not null
group by Col2
pivot Col1"))
to get xes try:
=ARRAYFORMULA(REGEXREPLACE(TO_TEXT(QUERY(SPLIT(FLATTEN(
IF(IFERROR(SPLIT(Sheet1!B1:B; ", "))="";;
Sheet1!A1:A&"♦"&SPLIT(Sheet1!B1:B; ", "))); "♦");
"select Col2,count(Col2)
where Col2 is not null
group by Col2
pivot Col1")); "^\d+$"; "x"))

Count data entries per day per person

My employees enter samples into our database. This is done by a forum. I have access to Google sheet that houses all the info they provide. They enter multiple entries a day. I am trying to find who is the top performer, that has entered the most entries in one day.
How do I get it to search my data to tell me the person's name and how many samples they are entered in per day?
Ex.
Tim= 15 entries on Sept 10
John= 5 entries on Sept 10
Brian= 2 entries on sept 10
Tim= 5 entries on sept 9
John= 20 entries sept 9
Brian= 1 entrie on sept 9
I want it to look through the list and pick up that Johns entries on the 9th are the highest and it outputs me johns name and 20 entries. Until a day comes that someone enters more than 20 entries it will hold john as being my top performer
you can use QUERY like:
=QUERY(A:C, "order by C desc limit 1", 0)
=QUERY(B2:E, "select B,count(B) where B is not null group by B label count(B)''", 0)
=QUERY(B2:E, "select B,count(B) where B is not null group by B pivot E", 0)
=ARRAYFORMULA(QUERY(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(QUERY(
{B2:B&"♦"&TEXT(E2:E, "m/d/yyyy")},
"select Col1,count(Col1)
where Col1 is not null
group by Col1
order by count(Col1) desc
label count(Col1)''", 0))&"♦",,999^99)), "♦"),
"limit 1
offset 1", 0))

Oracle : Selecting multiple columns with avg function

I am trying to display the average values of each player on a row by row basis with the player name
I have looked throughout the oracle docs and previous question asked by other people on stack overflow. I have only come across on how to select average value group by their record id and how to select avg using subquery
For an example,
What i found is to get the average by each row by
select round(avg(g1+g2+g3+g4)) as "Average Score" from ch_user group by playerid;
Do note that i didnt display my PlayerID shown in the picture .
If i were to select player and avg , it will give me ORA-01427. I have tried
select player, (select round(avg(g1+g2+g3+g4)) from ch_user group by playerid) as "Average Score" from ch_user;
But its prompting the error ORA-01427. single-row subquery returns more than one row.
Thank you in advance
UPDATED
I have already found the solution to the problem and i am able to implement it to my query based on #Boneist answer.
However, i find the query long, is there by any chance i could simplify the query ?
My query is
select first_name || ' ' || last_name as Player,game_1 as G1 , game_2 as g2 ,
game_3 as g3, game_4 as G4,total_score as "Total Tournament Score",
round(avg(game_1+game_2+game_3+game_4)) as "Average Score" from ch_user
group by playerid, first_name,last_name,game_1,game_2,game_3,game_4,total_score;
I think you've overthought this... all you need to do is add player into the select list in your first query and add player into the group by:
select player,
round(avg(g1 + g2 + g3 + g4)) as "Average Score"
from ch_user
group by playerid, player;
I think you want to group the data by player_id, but display player name and average. Check if this helps.
select player_name,round(avg(g1+g2+g3+g4)) "Average"
from ch_user
group by player_id,player_name;

obiee count distinct by as part of total count distinct

I need create following "numeric distribution" report in OBIEE :
item name,
count(distinct item_id by item_name),
count(distinct item_id by item_name)/count(distinct item_id)
(third column should be percent of count distinct by item name / count distinct by total)
How to get total count distinct ? I'm stuck and i will be appreciate any help.
The result should be:
Item 1 , 10, 50%
Item 2 , 20, 100%
where total number of customers is 20, and 10 od them buy Item_1, and 20 of them buy Item_2
Click on Measure in Pivot table then click on 'show Data as'>Percent of>Column.
Thats it

Resources