Googlesheets - Get the sum of a special string column - google-sheets

How can I sum up a sheet with many columns looks like below (list 3 column for example):
|-------+-----------|
| 1 | HKD 2,010 |
|-------+-----------|
| 2 | HKD 1,010 |
|-------+-----------|
| 3 | HKD 2,020 |
|-------+-----------|
| Total | HKD 5,050 |
|-------+-----------|

Try in B1:
=ARRAYFORMULA(sum(value(REGEXEXTRACT(B2:B, "[^' ']*$"))))

Related

Google Sheets - Conditional Formatting a dynamically resizing `Total` Row

I am trying to conditional format a dynamically resizing Total row of multiple tables stacked one above the other. The number of cells in the Total row may change depending upon the selection in a Year dropdown.
A | B | C | D | E | F | G | H | I | J | K | L | M |
<Year dropdown>
|Issues|2020-Jan|2020-Feb|2020-Mar|2020-Apr|2020-May|2020-Jun| | | | | | |
--------------------------------------------------------------------------------
| abc | 9 | 2 | 2 | 1 | 3 | 8 | | | | | | |
| def | 1 | 3 | 7 | 1 | 5 | 3 | | | | | | |
| ghi | 2 | 1 | 3 | 1 | 1 | 2 | | | | | | |
--------------------------------------------------------------------------------
|Total | 12 | 6 | 12 | 3 | 9 | 13 | | | | | | |
--------------------------------------------------------------------------------
I am using this formula to highlight the Total row. However, it is highlighting the entire row depending upon what range is set in the Conditional Formatting > Apply to Range box. I want to highlight only the numeric cells i.e. exclude blank cells.
=ISNUMBER(SEARCH("total",$B1))
This highlights the entire Total row including any blank cells. I modified it to exclude any blank cells in row, but no joy!
=AND(ISNUMBER(SEARCH("total",$B1)), SEARCH("total",$B1)<>""))
You can also do it like this, relying on relative addressing to modify the formula as it's effectively dragged across the formatted area:
=and(isnumber(search("Total",$B3)),B3<>"")
Use formula:
=(ISNUMBER(SEARCH("total",$B1))+(($B1:$Z1<>"")))>1

Automated way to create a confusion matrix in Google Sheets?

I have a table of this form in Google Sheets:
+---------+------------+--------+
| item_id | prediction | actual |
+---------+------------+--------+
| 1 | 1 | 1 |
| 2 | 1 | 1 |
| 3 | 1 | 0 |
| 4 | 0 | 1 |
| 5 | 0 | 0 |
| 6 | 1 | 1 |
+---------+------------+--------+
And I'd like to know if there's an automated way to get this kind of summary, with the counts of items that fit the criteria specified in that row/column combination:
+----------+--------------+--------------+-------+
| | prediction=0 | prediction=1 | total |
+----------+--------------+--------------+-------+
| actual=0 | 1 | 1 | 2 |
| actual=1 | 1 | 3 | 4 |
+----------+--------------+--------------+-------+
| total | 2 | 4 | |
+----------+--------------+--------------+-------+
I've been doing this somewhat manually in Google Sheets by using COUNTIFS, but I'm wondering if there's a built-in way? I tried using pivot tables, but couldn't figure out how to get the calculated fields to show the data I want.
A coworker figured it out - you can get this by creating a pivot table with the correct columns and rows, and setting the value to item_id summarized by COUNTUNIQUE.

Count occurrence by weekday in columns and row

I am having a google spreadsheet where the columns are specific dates and the rows are products.
| Weekdays | | | 2 | 3 | 4 | 5 | 6 |
| Activity | Streak | Max | 06.11.18 | 07.11.18 | 08.11.18 | 09.11.18 | 10.11.18 |
|-----------|--------|-----|----------|----------|----------|----------|----------|
| Product 1 | 0 | 5 | x | x | x | x | ... |
| Product 2 | 0 | 6 | x | | x | x | ... |
| Product 3 | 0 | 11 | x | x | x | x | ... |
| Product 4 | 0 | 7 | | | | | ... |
See my Data sheet.
On the tab Evaluation I tried to generate the following matrix, which should answer the question on which day of the week an occurrence of each of the products happened.
| Weekdays vs. Products | Product 1 | Product 2 | Product 3 | Product 4 |
|-----------------------|-----------|-----------|-----------|-----------|
| 1 | #N/A | #N/A | #N/A | #N/A |
| 2 | #N/A | #N/A | #N/A | #N/A |
| 3 | #N/A | #N/A | #N/A | #N/A |
| 4 | #N/A | #N/A | #N/A | #N/A |
| 5 | #N/A | #N/A | #N/A | #N/A |
| 6 | #N/A | #N/A | #N/A | #N/A |
| 7 | #N/A | #N/A | #N/A | #N/A |
I tried simply a =COUNTIF(Data!$2:$2;$B3;C$2;Data!A3), however as you can see above I get #N/A.
Any suggestions how to count for each weekday the occurrence of the product?
Appreciate your reply!
PS.: Find my example google spreadsheet here: google spreadsheet
Try
=countif(filter(filter(Data!$D$3:$BA;Data!$A$3:$A=C$13); Data!$D$1:$BA$1=$B14); "x")
and fill down and to the right as needed.
In Tabellenblatt3, I also added an alternitve approach, using a single formula. In cell B3 you'll find
=ArrayFormula(substitute(query(split(transpose(split(textjoin(;1;query(if(Data!D3:BA10="x";substitute(Data!A3:A10; " ";"/")&"_"&Data!D1:BA1&"_"&Data!D3:BA10;);;rows(Data!A3:A10)));" ")); "_"); "Select Col2, count(Col3) group by Col2 pivot Col1 label Col2 'Weekday'"); "/"; " "))
Note that this formula can break (because of the character limit in textjoin()) for large data sets.

Coloring cells based on numbers in string

In my sheet, on column A I have a string of numbers divided by commas. Then there are 12 numbered columns, each with its own hour. How can I shade the cells if their column's number is listed in column A?
Here is an example of what I am hoping to achieve.
| A | B | C | D | E
1 | | 1 | 2 | 3 | 4
2 | 1,2,4 | (shaded) | (shaded) | | (shaded)
3 | 2,3 | | (shaded) | (shaded) |
Select the whole range
Apply conditional fofmatting
select custom formula: =MATCH(B$1,SPLIT($A2,","),0)>0

Count occurrences of words from multiple columns

I have a spreadsheet like this, where the values A-E are the same options coming from a form:
+------+------+------+
| Opt1 | Opt2 | Opt3 |
+------+------+------+
| A | A | B |
| B | C | A |
| C | C | B |
| A | E | C |
| D | B | E |
| B | E | D |
+------+------+------+
I want to make a ranking, showing the most chosen options for each option. I already have this, where Rank is the ranking of the option and number is the count of the option:
+------+------+------+
| Rank | Opt1 | Numb |
+------+------+------+
| 1 | A | 2 |
| 1 | B | 2 |
| 3 | C | 1 |
| 3 | D | 1 |
+------+------+------+ (I have 3 of these, one for each option)
I want to do now a summary of the 3 options, making the same ranking but joining the options. It would be something like:
+------+------+------+
| Rank |Opt123| Numb |
+------+------+------+
| 1 | B | 5 |
| 2 | A | 4 |
| 2 | C | 4 |
| 4 | E | 3 |
| 5 | D | 2 |
+------+------+------+
The easiest way to do this would be getting the data from the three ranking tables or from the original three data columns?
And how would I do this?
I already have the formula to get the names of the options, the count and ranking, but I don't know how to make them work with multiple columns.
What I have (the F column is one of the data columns):
Column B on another sheet:
=SORT(UNIQUE(FILTER('Form Responses'!F2:F;NOT(ISBLANK('Form Responses'!F2:F)))); RANK(COUNTIF('Form Responses'!F2:F; UNIQUE(FILTER('Form Responses'!F2:F;NOT(ISBLANK('Form Responses'!F2:F))))); COUNTIF('Form Responses'!F2:F; UNIQUE(FILTER('Form Responses'!F2:F;NOT(ISBLANK('Form Responses'!F2:F))))); TRUE); FALSE)
Column C:
=ArrayFormula(COUNTIF('Form Responses'!F2:F; FILTER(B2:B;NOT(ISBLANK(B2:B)))))
Column A:
=ARRAYFORMULA(SORT(RANK(FILTER(C2:C;NOT(ISBLANK(C2:C))); FILTER(C2:C;NOT(ISBLANK(C2:C))))))
Edited:
Merge cols:
=TRANSPOSE(split(join(",",D2:D,E2:E),","))
merges 2 cols, not very clean, but works. (Same as here Stacking multiple columns on to one?)
Full formula:
=SORT(UNIQUE(FILTER(TRANSPOSE(split(join(",",D2:D,E2:E),","));NOT(ISBLANK(TRANSPOSE(split(join(",",D2:D,E2:E),",")))))); RANK(COUNTIF(TRANSPOSE(split(join(",",D2:D,E2:E),",")); UNIQUE(FILTER(TRANSPOSE(split(join(",",D2:D,E2:E),","));NOT(ISBLANK(TRANSPOSE(split(join(",",D2:D,E2:E),","))))))); COUNTIF(TRANSPOSE(split(join(",",D2:D,E2:E),",")); UNIQUE(FILTER(TRANSPOSE(split(join(",",D2:D,E2:E),","));NOT(ISBLANK(TRANSPOSE(split(join(",",D2:D,E2:E),","))))))); TRUE); FALSE)
The transpose could be done after the sort.

Resources