Excelerera ditt kunnande

– Bloggen som ger dig kraftfulla tips och trix till Excel

A touch of Unpivot and Pivot

Assuming (pyamas) table is named Table1 and located in cell B1 - not in A1.
A helping table below Table1 uses column A för the unique row values.
Finally assuming Excel 365 for dynamic arrays (spilling when needed).

__/ B10 Get Table1 columns/countries

=Table1[#Headers]
Dynamically shows the tables headers

__/ A11 Get Table1 row values

Dynamically extracts the unique row values;
=UNIQUE((FILTERXML("<tr><td>"&TEXTJOIN("</td><td>";1;Table1)&"</td></tr>";"//td")))

TEXTJOIN concatenates the tables values to look like an HTML table.
FILTERXML decodes it to one array of different cells
UNIQUE extracts the unique values

__/ B11:F11 The number of occurencies

=IFERROR(COUNTIFS(Table1 B:B;$A11#);0)

Same formula in cells B11:E11 and some more to get a margin for increased number of countries.
Parts of the formula explained;

Table1 B:B
means the intersection between the table and column B. This results in the tables column "USA" but without addressing it like Table1[USA] since that reference is not relative and thus not useful for repetition.

$A11#
means the result in cell A11.
$A means that the column is absolute and remains A when the cells is filled to more cells.
The hashmark, #, means that the cells spill range is included (dynamically includes all the tables row values)

COUNTIFS counts the occurencies and spills to show the result for each possible row value in the table column USA.

IFERROR makes the result zero if there is no column value/country (column F)

Filling B11 right to at least the number of columns (countries) is the one thing being not fully dynamic.


__/ Final report/table

Transpose the calculations to the wanted form;

B16=TRANSPOSE(A11#)
A17=TRANSPOSE(B10#)
B17=TRANSPOSE(B11#:F11#))


-/-

The layout may be better using different sheets for the three tables, thus making them indepent of a max number of rows in each table without reaching a table below.

https://ftp.excelerera.se/1006/a-touch-of-unpivot-and-pivot.xlsx

Originates from https://www.linkedin.com/groups/3124035/

Senaste artiklarna från Excelerera

I bloggen Excelerera listar vi tips & trix som hjälper dig få ut mer av ditt Excel-användande.

2020-10-14
Datum i Excel är egentligen heltal som räknar antal dagar. Här får du se hur du kan ändra formatet och minska risken att de missförstås.
2020-01-02
Har du någon gång haft en lista som du vill jämföra med en annan och hitta de som skiljer - eller är lika? Här beskrivs sex olika sätt att räkna fram de rader du är intresserad av.

Vill du veta mer?

Fyll i kontaktformuläret nedan så hjälper vi dig komma igång med PowerPage. Du kan även boka in en kostnadsfri konsultation för att få en bättre inblick i hur PowerPage kan hjälpa dig nå dina mål.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.