Forum Discussion

diegol81's avatar
diegol81
Copper Contributor
Oct 28, 2021
Solved

Formula to aggregate matrix spilling both rows and columns

Hi all,   I have an array originating in one cell and spilling both rows and colums: C5={5,2,1;7,3,4;9,10,8}   I also have row and column names that describe its contents: B5={"A";"A";"B"} C4=...
  • SergeiBaklan's avatar
    SergeiBaklan
    Feb 21, 2022

    diegol81 , you are welcome.

     

    For data only it's simpler

    uHeader = UNIQUE(header, 1);
    uLabels = UNIQUE(labels);
    
    onlyData=
    MAKEARRAY( ROWS(ulabels), COLUMNS(uHeader),
        LAMBDA( r, c,
            SUM(
                FILTER(
                    FILTER(
                        data,
                        (labels=INDEX(uLabels, r))  ),
                    header=INDEX(uHeader, c)
                )
            )
        )
    );
    

Resources