Summarize Data in Every Two Columns under Each Category
Judith-Excel-Sharing
Posted on July 10, 2024
Problem description & analysis:
In the Excel table below, column A contains categories and there are 2N key-value formatted columns after it:
We need to group rows by the category and the key and perform sum on detail data. The expected result set will have 3 columns. Note that the result set should be arranged according to the original order of the category column.
Solution:
Use SPL XLL to enter the following formula and drag it down::
=spl("=E(?).groupc@r(Country;;Label,Count).groups@u(Country,Label;sum(Count):Total)",A1:G11)
As shown in the picture below:
Explanation:
E()function reads data in its original table format. groupc@r performs column-to-row transposition by putting every n column in one group. groups() function performs grouping & aggregation.
Posted on July 10, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 23, 2024
July 16, 2024