Hi all,
I stumbled upon something weird while using the truncDate
function.
To add come context, I’m designing dashboards with some level of interactivity, just the basic stuff, date ranges, basic filtering, PoP calculations.
I followed some of the amazing stuff in this article and managed to make almost all of it to work.
The issue I’m having is when using the truncDate
function to truncate at the week level. I’m getting the data for the previous period, instead of the period for which start date and end date are set. This question is about this same issue.
Calculated field is:
ifelse(
${PeriodTypeParam}='Day',truncDate("DD",{status_created_ts}),
${PeriodTypeParam}='Week',truncDate("WK",{status_created_ts}),
${PeriodTypeParam}='Month',truncDate("MM",{status_created_ts}),
${PeriodTypeParam}='Quarter',truncDate("Q",{status_created_ts}),
truncDate("YYYY",{status_created_ts})
)
With the above I get:
Visual on the right is the data that should be shown, visual on the left is what I get.
I tried for the Month
and Year
period type and they both work fine.
I guess a workaround would be:
ifelse(
${PeriodTypeParam}='Day',truncDate("DD",{status_created_ts}),
${PeriodTypeParam}='Week',addDateTime(1, 'WK', truncDate("WK",{status_created_ts})),
${PeriodTypeParam}='Month',truncDate("MM",{status_created_ts}),
${PeriodTypeParam}='Quarter',truncDate("Q",{status_created_ts}),
truncDate("YYYY",{status_created_ts})
)
Any insights and/or assistance into this will be appreciated.
Thanks,