O
O
OpenReligion2019-03-18 11:55:39
Google Sheets
OpenReligion, 2019-03-18 11:55:39

How to count how many times each numeric value occurs in a string?

I have an array with 10 columns and a lot of rows.
I need to count how many times each numeric value occurs in an array.
This is easy to do through COUNTIF , but
the difficulty for me is that if the same values ​​\u200b\u200bare found in one line, then it only needs to be calculated once.
maqztr9gmgqawbe3goqvxqssbz8.png
The UNIQUE function works for columns, but when applied to a row, it simply repeats the original row.
Can you suggest how to proceed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Bcoon, 2019-03-18
@OpenReligion

Solution:
1) Formula for extracting a list of uniques with sorting:
=SORT(UNIQUE(TRANSPOSE(SPLIT(JOIN(",";A1:J1;A2:J2;A3:J3);","))) )
2) Formula to count the number of occurrences
Initial data in the range A1:J3
5c8fab78b9fc9629594505.png

A
Alexander Ivanov, 2019-03-18
@oshliaer

You are probably looking for something like

=QUERY(TRANSPOSE(SPLIT(TEXTJOIN("·",TRUE,A1:C6),"·")),
  "select Col1, count(Col1) group by Col1")

5c8f91249f68a830389519.png
Sorry, no source file, but should probably work for small sizes.
Doesn't work with strings. Treats void as 0.
=ARRAYFORMULA(QUERY(
  TRANSPOSE(SPLIT(TEXTJOIN(
    "·";
    TRUE;
    A1:D6*(1=COUNTIFS(A1:D6;A1:D6;COLUMN(A1:D6)*ROW(A1:D6)^0;"<="&COLUMN(A1:D6)*ROW(A1:D6)^0;COLUMN(A1:D6)^0*ROW(A1:D6);COLUMN(A1:D6)^0*ROW(A1:D6)))
  );"·"));
  "select Col1, count(Col1) group by Col1"
))

5c8fc1137d805046955363.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question