Google Sheets: Consolidate Rows By Unique ID - google-sheets

I'm trying to consolidate crypto data from BscScan, by ID (a Hash in this case). As the downloaded data has many irrelevant columns, and actual hash data is very long, I've created a simple abbreviated data example of what I'm trying to do:
For each Hash, I need to
Sum the "Number" column
Count the Number of Records
Some pointers on how to do this would be appreciated.

Please try this QUERY
=QUERY(A2:B14, "select A, sum(B), count(B)
where A <>'' group by A
label sum(B) 'Total', count(B) 'Record Count' ",1)

Related

TextJoin the rows based on the Id's dates and sequence

I have been trying to concatinating the Specific column based on the ID's, dates and the sequence which are avaialble in the separate columns.
I have used 3 steps to get the result and the result is accurate but i want to use a single formula or Google sheets Query to achieve the final result.
I have added a google sheets for your reference and i would really appreciate your help in this regards.
1st step In this step i just Sorted out the data
=QUERY({'Raw Data'!A:F}, "SELECT Col2, Col3, Col4, Col5 Where Col2 is not null ORDER BY Col2 ASC, Col4 ASC, Col3 ASC")
2nd step From Sorted out data i have taken 2 column and make them unique then used textjoin function to concatenate the notes with before and after brackets.
=UNIQUE(QUERY(A2:D, "SELECT A,C"))
=TEXT(G3,"MM-DD-YYYY")&": ("&TEXTJOIN(" ",TRUE,FILTER(D:D,A:A=F3,C:C=G3))&")"
3rd step after all above steps i pulled the only unique id's then based on unique id's textjoin the notes
=UNIQUE(F2:F)
=TEXTJOIN(" ",TRUE,FILTER(H:H,F:F=L3))
Added formula to your sheet to test:
=index(let(a,sort({B2:E},1,1,3,1,2,1),b,unique(filter({index(a,,1),index(a,,3)},index(a,,1)<>"")),c,map(index(b,,1),index(b,,2),lambda(d,e,"("&join(" ",filter(index(a,,4),index(a,,1)=d,index(a,,3)=e))&")")),byrow(unique(tocol(index(b,,1),1)),lambda(z,{z,join(" ",unique(filter(TEXT(index(b,,2),"mm-dd-yyyy")&": "&c,index(b,,1)=z)))}))))

SELECT DISTINCT values grouping for one columns in Google Sheets Query

Let´s say I have this set of dummy data in a .gsheet spreadsheet which Sheet is called Sheet11:
I need to get the following output:
which means that I´d be selecting column A corresponding to the projects, counting the users in column B where the Billable is equals TRUE, and then grouping by A and last ordering by the column counted B.
Applying the query formula =query(Sheet11!A1:C13,"select A,count(B) where C=TRUE group by A order by count(B) desc",1), I am getting this:
It counts all the users assigned to project1 and all assigned to project2, I´d need to get the count of unique users for both projects.
How could I apply some kind of unique like in SQL?
You can use subselect:
=query(query(A1:C13,"select A,B, count(B) where C=TRUE group by A,B",1),"SELECT Col1, COUNT(Col2) GROUP BY Col1 ORDER BY COUNT(Col2) desc")

How can I separate a column into multiple columns based on values?

I have searched on a lot of pages but I cannot find a solution to my problem except in reverse order. I have simplified what I do, but I have a query that comes looking for information in my data sheet. Here there are 3 columns, the date, the amount and the source.
I would like, with a query function, to be able to make different columns which counts the information of column C based on the values of its cells per month, like this
I'm okay with the start of the formula
=QUERY(A2:C,"select month(A)+1, sum(B), count(C) where A is not null group by month(A)+1")
But as soon as I try a little different things by putting 2 query together in an arrayformula, obviously the row count doesn't match as some minus are 0 for some sources.
Do you have a solution for what I'm trying to do? Thank you in advance :)
Solution:
It's not possible in Google Query Language to have a single query statement that has one result grouped by one column and another result grouped by another.
The first two columns can be like this:
=QUERY(A2:C,"select month(A)+1, sum(B) where A is not null group by month(A)+1 label month(A)+1 'Month', sum(B) 'Amount'")
To create the column labels for the succeeding columns, use in the first row, in my example, I1:
=TRANSPOSE(UNIQUE(C2:C))
Then from cell I2, enter this:
=COUNTIFS(arrayformula(month($A$2:$A)),$G2,$C$2:$C,I$1)
Then drag horizontally and vertically to apply to the entire table.
Results:
try:
=INDEX({
QUERY({MONTH(A2:A), B2:C},
"select Col1,sum(Col2) where Col2 is not null group by Col1 label Col1'month',sum(Col2)'amount'"),
QUERY({MONTH(A2:A), B2:C, C2:C},
"select count(Col3) where Col2 is not null group by Col1 pivot Col4")})

In Google Sheets, how to query and sum all values which have the same description?

I am using a query formula to import data from a different sheet.
However after querying the data, I got the same code which I need to sum the episode and the value with unique formula therefore after querying only show unique code. I'm not sure how to mix the formula.
My query formula is the following:
=QUERY(Paste!A:M,"SELECT A,B,C ORDER BY C DESC LIMIT 15")
My spreadsheet link is the following:
https://docs.google.com/spreadsheets/d/1A6lGIlU147Y_0WFD7Btkq4IMuY-Z3D1HsNiTgjLjm0o/edit?usp=sharing
As above image. Under column A I have same code for FMEM1 due to my raw data separate it for some reason. I don't want the same code separated. I want unique code not separated and sum the episode and sum the value
try
=query({A3:A17,B3:B17,C3:C17},"select Col1, Sum(Col2),Sum(Col3) group by Col1 label Col1 'Code',Sum(Col2) 'Total Episode',Sum(Col3) 'Total Value'")
Screenshot

List unique values grouped by another column

In Google Sheets, I need to extract the unique values in column B, for every unique value in column A, such that I can construct the following table:
Possible?
=Unique(A:B)
should be enough to return non-duplicate rows
https://support.google.com/docs/answer/3093198?hl=en
You can also use Sortn:
=sortn(A:B,9E+99,2,1,true,2,true)
=QUERY(QUERY(A1:B,
"select A, B, count(A)
group by A, B", 1),
"select Col1, Col2
where Col1 is not null", 1)
You can also install my add-on called Flookup and use the function below:
ULIST(colArray, [indexNum], [threshold])
colArray The range from which you want to return unique values.
indexNum The column index to analyse for unique values.
threshold The percentage similarity between the non-unique values. This helps eliminate potential duplicates.
So for your case you would simply type:
=ULIST(A1:B6, 2)
Find out more details at the official website.

Resources