Reverse Running Totals

Looker will not be updating this content, nor guarantees that everything is up-to-date. 

Starting in Looker 21.12, you can use Quick Calculations to perform common calculations on numeric fields that are in an Explore's data table without using Looker functions and operators when the Custom Fields Labs feature is enabled, and you have permission to use them.


You can create running totals very easily with a table calculation that will sum the numbers going down the columns. If you switch the sorting, you will still get running totals going downward.

What if you want to sort your data newest to oldest and have the running total calculated bottom to top? You can also do this with table calculations.

Suppose I had a measure called "Flights Count" and wanted to sort by years in descending order, like the following table:

09a021d6-e122-4d32-87eb-74533f87af12.png

The reverse running total is created with two table calculations:

  • The first is just a normal running total:

    67967730-3143-48dd-98af-8a25079d71ed.png
  • The second gets the sum of "Flights Count" for the first row, then each subsequent row subtracts the running total from the sum:

    1c200c94-65ea-4578-bc02-611a7739b17e.png
Comments
edgar_encarnaci
New Member

Really helpful information, thank you!

Version history
Last update:
‎06-22-2022 03:54 PM
Updated by: