– Bloggen som ger dig kraftfulla tips och trix till Excel
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).
=Table1[#Headers]
Dynamically shows the tables headers
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
=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.
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/
I bloggen Excelerera listar vi tips & trix som hjälper dig få ut mer av ditt Excel-användande.
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.