How do I count all cells in a column that have emoji? - google-sheets

I have a problem with emoji in my production database. Since it's in production, all I get out of it is an auto-geneated excel spreadsheet (.xls) every so often with tens of thousands of rows. I use Google Sheets to parse this so I can easily share the results.
What formula can I use to get a count of all cells in column n that contain emoji?
For instance:
Data
+----+-----------------+
| ID | Name |
+----+-----------------+
| 1 | Chad |
+----+-----------------+
| 2 | ✨Darla✨ |
+----+-----------------+
| 3 | John Smith |
+----+-----------------+
| 4 | Austin ⚠️ Powers |
+----+-----------------+
| 5 | Missus 🎂 |
+----+-----------------+
Totals
+----------------------------------+---+
| People named Chad | 1 |
+----------------------------------+---+
| People with emoji in their names | 3 |
+----------------------------------+---+

Edit by Ben C. R. Leggiero:
=COUNTA(FILTER(A2:A6;REGEXMATCH(A2:A6;"[^\x{0}-\x{F7}]")))

This should work:
=arrayformula(countif(REGEXMATCH(A2:A6,"[^a-zA-Z\d\s:]"),true))

You cannot extract emojis with regular formula because Google Spreadsheet uses the light-weight re2 regex engine, which lacks many features, including those necessary to find emojis.
What you need to do is creating a custom formula. Select Tools menu, then Script editor.... In the script editor, add the following:
function find_emoji(s) {
var re = /[\u1F60-\u1F64]|[\u2702-\u27B0]|[\u1F68-\u1F6C]|[\u1F30-\u1F70]|[\u2600-\u26ff]|[\uD83C-\uDBFF\uDC00-\uDFFF]+/i;
if (s instanceof Array) {
return s.map(function(el){return el.toString().match(re);});
} else {
return s.toString().match(re);
}
}
Save the script. Go back to your spreadsheet, then test your formula =find_emoji(A1)
My test yields the following:
| Missus 🎂 | 🎂 |
| Austin ⚠️ Powers | ⚠ |
| ✨Darla✨ | ✨ |
| joke 😆😆 | 😆😆 |
And, to count entries that don't have emojis, you can use this formula:
=countif( arrayformula(isblank( find_emoji(filter(F2:F,not(isblank(F2:F)))))), FALSE)
EDIT
I was wrong. You can use regular formula to extract emoji. The regex syntax is [\x{1F300}-\x{1F64F}]|[\x{2702}-\x{27B0}]|[\x{1F68}-\x{1F6C}]|[\x{1F30}-\x{1F70}]|[\x{2600}-\x{26ff}]|[\x{D83C}-\x{DBFF}\x{DC00}-\x{DFFF}]

Related

Fill in blank cells from several columns in ={ARRAYFORMULA()}

I have a human-friendly sheet with sparse hierarchical data:
SEASON | FRUIT | LETTER
-----------------------------
Winter | |
| Lemons |
| | Delta
Summer | |
| | Alpha
| | Beta
| Pears |
| | Gamma
(Note how Alpha and Beta don't have a FRUIT entry.)
I want to generate a new column, using ARRAYFORMULA(), to contain a full "path" to the LETTER:
SEASON | FRUIT | LETTER | PATH
------------------------------------
Winter | | | Winter//
| Lemons | | Winter/Lemons/
| | Delta | Winter/Lemons/Delta
Summer | | | Summer//
| | Alpha | Summer//Alpha
| | Beta | Summer//Beta
| Pears | | Summer/Pears/
| | Gamma | Summer/Pears/Gamma
Please help me to understand how to write such ARRAYFORMULA().
I'm trying approach, based on answers in Fill in blank cells in ={ARRAYFORMULA()}, but I'm stuck at resetting FRUIT to empty string for a new SEASON. I.e. this naïve implementation would yield Summer/Lemons/Alpha instead of Summer//Alpha:
={ ARRAYFORMULA(
IFERROR(VLOOKUP(ROW(SEASON), IF(SEASON<>"", { ROW(SEASON), SEASON }), 2, 1), "")
& "/" & IFERROR(VLOOKUP(ROW(FRUIT), IF(FRUIT<>"", { ROW(FRUIT), FRUIT }), 2, 1), "")
& "/" & LETTER
) }
Here is a sample spreadsheet created specifically to answer this question.
you will find this formula in cell E1 on a tab called Possible Solution.
=ARRAYFORMULA(IF(LEN(A:A&B:B&C:C),VLOOKUP(ROW(A:A),FILTER({ROW(A:A),A:A},LEN(A:A)),2,1)&"/"&VLOOKUP(ROW(B:B),FILTER({ROW(B:B),B:B},LEN(A:A&B:B)),2,1)&"/"&C:C,))
It uses the VLOOKUP(ROW(),FILTER(),[index],TRUE) technique to append the relevant parts of the path to one another.
Note the portion of the formula in the image which i believe was the crux of the trouble with the strategy you were trying...

Partial transpose of Sheet

I have a Google Sheet with this format:
+---------+---------+---------+------------+------------+------------+------------+--------+--------+
| Field_A | Field_B | Field_C | 24/09/2019 | 25/09/2019 | 26/09/2019 | 27/09/2019 | day... | day... |
+---------+---------+---------+------------+------------+------------+------------+--------+--------+
| ValX | ValY | ValZ | Val1 | Val2 | Val3 | Val4 | | |
| ValW | ValY | ValZ | Val5 | Val6 | Val7 | Val8 | | |
+---------+---------+---------+------------+------------+------------+------------+--------+--------+
First 3 columns are specific fields and all other columns are related to one specific day in a given (and static) range.
I need to convert the table in the following format:
+---------+---------+---------+------------+-----------+
| Field_A | Field_B | Field_C | Date | DateValue |
+---------+---------+---------+------------+-----------+
| ValX | Valy | Valz | 24/09/2019 | Val1 |
| ValX | Valy | Valz | 25/09/2019 | Val2 |
| ValX | Valy | Valz | 26/09/2019 | Val3 |
| ... | | | | |
+---------+---------+---------+------------+-----------+
Basically, the first 3 columns are gathered as-is, but the day-column in transposed (is even the correct term?) with 2 values:
The date
The value in the cell related to date
Is something that can be achieved with formula or do I need to create a bounded AppsScript?
Following a sample Sheet demo: https://docs.google.com/spreadsheets/d/1cprzD96i-4NQ8tieA_nwd8s43yKF-M8Kww4yWNfB6tg/edit#gid=505040170
In Sheet Start you can see the initial data and format, 3 static columns and one column for every da
In Sheet End you can see the output format I'm looking for, the same 3 static columns, but the date and cell value related to date are transposed as a row.
You can see the Formula I used, TRANSPOSE for every row, where I select the days for the IV column and one row at a time for the V row.
For the 3 static columns, I replicated the Formula for every instance of the day related to that row.
This is working but requires much manual work to set up every single TRANSPOSE. I'm wondering if there is a more automatic way of doing this (except for using AppsScript, in that case, I'm already planning on doing this if not other solutions are available)
=ARRAYFORMULA(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(Start!D2:F<>""; "♦"&TRANSPOSE(QUERY(TRANSPOSE(Start!A2:C&"♠");;999^99))&
TEXT(Start!D1:F1; "dd/mm/yyyy")&"♠"&Start!D2:F; ));;999^99));;999^99); "♦")); "♠")))

Google Sheets function Address() results in adding unwanted characters ''! when used in ArrayFormula

If you look at the following table in Column A I have some values that I want to use to make an address reference. I can successfully accomplish this with the formula in Column C copied down into each cell. I would like to use the more dynamic ArrayFormula so that when even I enter a new row it will populate with the correct Address. However, it's injecting ''! before my addresses. I don't know what to do to get rid of it.
I have a workaround in another column in row 3 I enter this. =ARRAYFORMULA(IF(LEN(B3:B), MID(B3:B,4,5),)) however I feel the address should just work without it. Anyone know why it does the unnecessary injection ''!.
link to example Sheet
+------------+---------------------------------------------------------------+-----------------------------+
| | Incorrect but dynamic | Correct if but not dynamic |
+------------+---------------------------------------------------------------+-----------------------------+
| Formula -> | ARRAYFORMULA(IF(LEN(A3:A), ADDRESS(Row(A3:A),A3:A,4,TRUE,),)) | ADDRESS(Row(A3),A3,4,TRUE,) |
| 1 | ''!A3 | A3 |
| 2 | ''!B4 | B4 |
| 3 | ''!C5 | C5 |
| 4 | ''!D6 | D6 |
| 5 | ''!E7 | E7 |
| 1 | ''!A8 | A8 |
+------------+---------------------------------------------------------------+-----------------------------+
=ARRAYFORMULA(IF(LEN(A3:A),SUBSTITUTE(ADDRESS(ROW(A3:A),A3:A,4,1,),"''!",""),))

How to achieve conditional formatting of names between pages?

I have a Google Sheet with one page for team leaders to list their desired team members (first names, last names, emails) by row--each TL fills in one row--, and a second page where team members are listed who have actually registered with my program.
Page 1
+------------------------+------------+---------------+------------+--------------------+
| Team Leader First Name | First Name | Email Address | First Name | Email Address |
+------------------------+------------+---------------+------------+--------------------+
| Danielle | Elizabeth | XXX#tamu.edu | Matthew | XXX#tamu.edu |
| Stoian | William | XXX#tamu.edu | Victoria | XXX#email.tamu.edu |
| Christa | Olivia | XXX#tamu.edu | | |
+------------------------+------------+---------------+------------+--------------------+
Page 2
+--------------------+-------------------------+
| Scholar First Name | Scholar Preferred Email |
+--------------------+-------------------------+
| elizabeth | xxx#gmail.com |
| william | xxx#tamu.edu |
+--------------------+-------------------------+
I want to be able to see at a glance which of the names listed by the TL on pg 1 have not registered and thus don't appear on pg 2.
In the example above, I want Olivia, Matthew, and Victoria's names to appear red because she does not show up on pg2 (which means they still need to register). Everyone else should appear normally.
I tried at first to importrange from pg1 to get a clean list of the team members, then conditional formatting to match against pg2, the idea I had being it shows up red if a name is not found.
Import range from page 2 to page 1 the scholar first name to F12:F14
Conditional Formatting: Apply to range B2:B999(first name list in page 1)
=NOT(OR(ISNUMBER(MATCH(TRIM(B2),$F$12:$F$13,0)),ISBLANK(B2)))
Conditional Formatting2: Apply to range D2:D999(Second First name list)
=NOT(OR(ISNUMBER(MATCH(TRIM(D2),$F$12:$F$13,0)),ISBLANK(D2)))
Note: Instead of importing, You could also reference the second sheet using INDIRECT.

Trying to find a Google Spreadsheet formula or query for this example

A | B | C | D | E | F | G
name|num|quant|item|quant2
car | 5 | 100 |
| | |wheel| 4
| | |axel | 2
| | |engine|1
truck| 2 | 20 |
| | |wheel| 6
| | |bed | 1
| | | axel| 2
I need a formula which will do B*C*E. the tables look like this, so it needs to be something like
=b$2*c$2*e3 and then dragged.... and then the next set, b$6*c$6*e7 and dragged, etc but i want sure how to get the cieling sort of something. if b5 is empty, look at each above until it finds the one not filled.
I am trying to use this to get total quantity of parts per car, truck etc.... and then group by part.
I dont have a set of DB tables to do this, just a spreadsheet.
I had to add some additional information to resolve this.
I was thinking there would be a way to do a google script that would do this and update the file, but i couldnt seem to find it.
I first summed each group item:
=b$3*e4
and dragged for that grouping.
Then afterwards, i went to a selection of space and wrote up a query.
=query(D:F, "select D,sum(F) group by D")

Resources