#50 — Group And Summarize Rows And Add Different Words After Different Counts

Problem description & analysis:

An Excel table has two columns:

Task: Group the table by the 1st column, and add 1 if the 2nd column in the current group is greater than 0; otherwise, do not add 1. If the count equals 1, add the word “Occurrenc…


This content originally appeared on DEV Community and was authored by Judith-Excel-Sharing

Problem description & analysis:

An Excel table has two columns:

original table

Task: Group the table by the 1st column, and add 1 if the 2nd column in the current group is greater than 0; otherwise, do not add 1. If the count equals 1, add the word “Occurrence” after it; if it doesn’t, add its plural form “Occurrences” after it. Below is the expected result:

desired table

Solution:

Use SPL XLL to do this:

=spl("=E@b(?.group(~1;t=~.count(~2>0) / if(t==1,""Occurrence"",""Occurrences"")))",A1:B8)

As shown in the picture below:

result table with code entered
Explanation:

group() function groups rows and handles each group of data. E@b removes column titles. ~1 represents the 1st child member of the current member in a sequence.


This content originally appeared on DEV Community and was authored by Judith-Excel-Sharing


Print Share Comment Cite Upload Translate Updates
APA

Judith-Excel-Sharing | Sciencx (2024-08-23T07:36:26+00:00) #50 — Group And Summarize Rows And Add Different Words After Different Counts. Retrieved from https://www.scien.cx/2024/08/23/50-group-and-summarize-rows-and-add-different-words-after-different-counts/

MLA
" » #50 — Group And Summarize Rows And Add Different Words After Different Counts." Judith-Excel-Sharing | Sciencx - Friday August 23, 2024, https://www.scien.cx/2024/08/23/50-group-and-summarize-rows-and-add-different-words-after-different-counts/
HARVARD
Judith-Excel-Sharing | Sciencx Friday August 23, 2024 » #50 — Group And Summarize Rows And Add Different Words After Different Counts., viewed ,<https://www.scien.cx/2024/08/23/50-group-and-summarize-rows-and-add-different-words-after-different-counts/>
VANCOUVER
Judith-Excel-Sharing | Sciencx - » #50 — Group And Summarize Rows And Add Different Words After Different Counts. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/23/50-group-and-summarize-rows-and-add-different-words-after-different-counts/
CHICAGO
" » #50 — Group And Summarize Rows And Add Different Words After Different Counts." Judith-Excel-Sharing | Sciencx - Accessed . https://www.scien.cx/2024/08/23/50-group-and-summarize-rows-and-add-different-words-after-different-counts/
IEEE
" » #50 — Group And Summarize Rows And Add Different Words After Different Counts." Judith-Excel-Sharing | Sciencx [Online]. Available: https://www.scien.cx/2024/08/23/50-group-and-summarize-rows-and-add-different-words-after-different-counts/. [Accessed: ]
rf:citation
» #50 — Group And Summarize Rows And Add Different Words After Different Counts | Judith-Excel-Sharing | Sciencx | https://www.scien.cx/2024/08/23/50-group-and-summarize-rows-and-add-different-words-after-different-counts/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.