A
A
Alina Shah2021-07-16 16:21:47
Google Sheets
Alina Shah, 2021-07-16 16:21:47

How to spread the digits of a number into cells with an additional condition?

The task may sound complicated, I'm sure there is a simple solution :)
https://docs.google.com/spreadsheets/d/1vqKnsN_8qQ...

  1. move a two-digit number from one cell to two different cells
  2. and if it is more than 22, then subtract 22 from it and put several numbers in the third cell and so on.
  3. group all zeros in one cell, separated by a space, all ones in another cell separated by a space, and so on up to 22. There may be no numbers for some.

See the link in the table for details.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2021-07-19
@Shah_Alina

I am a big fan of Grigory Boev , but it seemed to me that not everything would be so simple. Yes, the algorithm should not be changed, but the essence of some formulas can be simplified. For example, spacing numbers in pairs
=REGEXEXTRACT("" & B8;"(\d\d)(\d\d)(\d\d)(\d\d)")
60f50b9857f5b905414802.png
or comparing with "22"
=IF(--C8>22;REGEXEXTRACT(C8;"(\d)(\d)"); C8)
60f50bf3b08c5236370326.png
This is a more appropriate option. You need to watch the data types. Usually there are rows that often the Table "wants" to automatically turn into numbers.
Final count

=INDEX(SORTN(TRANSPOSE({
  IF({B19:L19\B28:L28}="";"";--{B19:L19\B28:L28});
  TRIM(QUERY(
    IF("" & TRANSPOSE({B19:L19\B28:L28})="" & {B19:L19\B28:L28};IF({B19:L19\B28:L28}="";"";--{B19:L19\B28:L28}););
    ;
    9^9))
});9^9;2;1;1);;2)

60f50d09a09ec782340420.png
Example in Spreadsheet https://docs.google.com/spreadsheets/d/19bQjuZpRaE...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question