Thomas Karbe
08/12/2024, 11:30 AMFOR PreviousPeriod
in combination with a time filter on the board. E.g. I want to create a report that shows a metric on a monthly basis, next to the same value 12 months ago. As soon as I limit this board to show the current 12 months, the metrics doesn’t pull the 12M comparison in anymore. How can I change this?Francisco Antunes
08/12/2024, 12:41 PMRevenue
metric. So I built a simple PreviousPeriod version of it, like so:
SELECT Revenue FOR PreviousPeriod(Year (Date))
I added it to an Insight, trending by Date(Month) (see the first screenshot), and added this insight to a Dashboard. Even when I filter the dashboard to limit it to a single year, it will still show the PreviousPeriod value.
That’s how it should work, since PreviousPeriod actually calculates based on the current filtered date values - so it shouldn’t matter if, for example, you are limited to a single year on the Dashboard filter - you’ll still see values from the previous year, but the data point is still from the current year, if that makes sense.
Would you show me in a bit more detail how you are reaching the behavior you described?Thomas Karbe
08/12/2024, 12:45 PMFrancisco Antunes
08/12/2024, 1:11 PMOn the other hand, FOR PreviousPeriod( ) adapts to the context of the report at hand. Regardless of the date attribute specified by the metric author, the PreviousPeriod( ) function takes on the date attribute of the smallest granularity from the report.So if you use FOR PreviousPeriod(Year) on your metric, for example, but slice it by Month, the metric will actually show the value for the previous Month (the new smallest granularity), not the previous year. That seems to cause the offset values on the graph. So to show the previous year in an insight with the Month granularity, the metric would actually have to be:
SELECT Revenue FOR PreviousPeriod(Year (Date),12)
Which, in the context of the insight/dashboard, ends up being the same as:
SELECT Revenue FOR Previous(Month/Year (Date),12)
Since both of those end up giving you the same value, I would recommend using the second example as a solution, since it’s simpler to understand - that will fix your time frame and ensure that the values are both correct and aligned in the final insight.
Please give it a shot and let me know if it works out better!Thomas Karbe
08/12/2024, 1:19 PMThomas Karbe
08/12/2024, 1:45 PMThomas Karbe
08/12/2024, 1:46 PMFrancisco Antunes
08/12/2024, 2:23 PMThomas Karbe
08/12/2024, 3:11 PM