Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Is there a way to compare PY to current year on a time trend chart with month-year (e.g. 2018 Aug) rather than month on the X axis?
Dimension: year_month
Measure (current): sum({<year={$(vMaxYear)}>}[kpi_value])
Measure (PY): sum({<year={$(vPreviousYear)}>}[kpi_value])
This produced the following chart:
Is there a way to have make the chart look like this instead (but with year-month, not month on X axis):
Try out this alternative approach where I use The As Of Table to do this by creating this at the end of the script
AsOfTable: LOAD DISTINCT month as AsOfMonth, year as AsOfYear, month, 'CY' as Flag Resident Table; Concatenate(AsOfTable) LOAD DISTINCT month as AsOfMonth, year as AsOfYear, Date(MonthStart(month, -12), 'YYYYMM') as month, 'PY' as Flag Resident Table;
and then use these
Dimension
AsOfMonth
Expressions
If(GetSelectedCount(AsOfMonth) > 0, Sum({<Flag = {'CY'}>}[kpi_value]), Sum({<year={$(vMaxYear)}, Flag = {'CY'}>}[kpi_value])) If(GetSelectedCount(AsOfMonth) > 0, Sum({<Flag = {'PY'}>}[kpi_value]), Sum({<Flag = {'PY'}, AsOfYear={$(vMaxYear)}>} [kpi_value]))
Change the PY expression to this
Above(Sum({<year = {$(vPreviousYear)}>} [kpi_value]), 12)
Thank you Sunny, the formula works! Although:
The reason I need year-month is so that I would be able to select the same month from different years from the filter to compare on the chart, e.g. 2018 July and 2017 July. However, with the above formula (Above(Sum({<year={$(vPreviousY)}>} [kpi_value]), 12)) when I select these two months from the filter, I see only one bar on the chart (2018 July). Is there a way to adjust the formula to allow for that comparison?
Which two bars are you looking to get? July 2017 and July 2018?
Yes, so I have year_month as a filter, and I would like to be able to select any month from there and have them displayed on the chart (so e.g. 2018 July and 2017 July)
So, why have you used this set analysis
{<year={$(vMaxYear)}
This is forcing your expression to show Max(Year) which is 2018... I guess you need to remove that?
But I need to have only months from the latest year displayed on the chart (unless specific months are selected in filter) - how else could I do that without that set analysis?
Then in that case... try something like this out
If(GetSelectedCount(Month) = 0, With Set Analysis expression, Without Set Analysis expression)
Thanks Sunny, that worked!
When a specific month is selected, PY trendline disappears (only current is displayed) though, is there a way to keep when a filter selection is applied?