2

I am generating a pivot table in Google Sheets, but when new categories are added to the data, the size of the pivot table changes. Therefore I cannot extract data from certain cells of the table.

For example: I want to import the grand total number of the pivot table, which is in cell (D,5). But if the data is changed and another field is added to the columns of the table, the grand total is now in cell (E,5).

Is there a way to make the pivot table fixed size or to tell function to take the last element in a table?

1 Answer 1

1

I don't see how fixing the size could work, but you can get the contents of the last nonempty cell in the 5th row with the following function:

=array_constrain(sort(transpose(filter({A5:5; column(A5:5)}, len(A5:5))), 2, false), 1, 1)

Explanation

  • {A5:5; column(A5:5)} creates an array with entries of 5th row, along with their column numbers
  • filter removes the columns where the 5th row entry is empty
  • sort(transpose(...), 2, false) sorts in decreasing order of columns numbers, effectively reversing the order
  • array_constrain(..., 1, 1) picks the first element of the new array, which was originally last.
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.