I have a spreadsheet with dynamic columns. I'd like to sum the columns by adding a row. I have found how to sum rows with Query but not columns.
My queries are below and I want to add at the end of each of them the sum of the columns.
=
{
INDEX(QUERY(QUERY({Staffs!A2:1000},
"select Col1,"&TEXTJOIN(",", 1,
"sum(Col"&SEQUENCE(COUNTA(Staffs!B1:1), 1, 2)&")")&"
where Col1 is not null
group by Col1"),
"offset 1", 0));
{" ",ArrayFormula(EDATE(eomonth(Salaries!L1,0),SEQUENCE(1,7*12-MONTH(Salaries!L1)+1,0,1)))};
INDEX(QUERY(QUERY({Salaries!N2:1000},
"select Col1,"&TEXTJOIN(",", 1,
"sum(Col"&SEQUENCE(COUNT(TRANSPOSE(Salaries!O2:2)), 1, 2)&")")&"
where Col1 is not null
group by Col1"),
"ORDER BY Col1 ASC offset 1", 0))
}
The spreadsheet can be viewed there: https://docs.google.com/spreadsheets/d/1veiYh1CMIfFPwBGQk4OwKmCLa7q08TugReVfAXtpIgI/edit#gid=280688035
Basically I want to calculate the sum for each month for the number of staffs and the salaries
Thank you!