I’m working with a dataset that shows energy usage for buildings, and trying to figure out how to display an energy intensity calculation as a line over the top of a bar chart of usage, but the the time windows aren’t necessarily the same and I’m struggling to figure out how to do this.
I’m using a stacked bar combo chart, with energy usage shown in the bars using the kBtu
field and color-coded by the Commodity
field. The whole chart is then grouped by Building
, and filtered to a time window controlled by two parameters, startDate
and endDate
. The result is a bar chart showing the aggregated energy usage by building for whatever the selected time window is (default is 12 months).
The Energy Usage Intensity (EUI) line I want to overlay on that is a rolling 12-month number, calculated by adding up the last 12 months (relative to endDate
) of energy usage and dividing by the area of the building in square feet. Here’s the formula I’m using for that:
windowSum(
sum({kBtu}),
[{Building} ASC],
11,
0
)
/ max({Area})
This works fine as long as the startDate
and endDate
parameters stay at their default settings of 12 months apart. However, if I change one of those dates so that the window between them is less than 12 months, the EUI calculation no longer works correctly, because the date filter is applied before it gets a chance to look at the data. So if I change it to look at 8 months (shown in my screenshot below), it only sums up 8 months of energy usage before dividing by the building area, and the numbers turn out wrong.
Is there a way for me to perform this calculation pre-filter so that even if I’m displaying less than 12 months on the chart, the calculation still looks back that far? The windowSum
function doesn’t offer a PRE_FILTER option, and I tried the “date hider” trick here but because I’m using Building
on the x-axis instead of a date it just complains about missing a table calculation field.