我必须创建一个带有维度的 qliksense 折线图,该维度仅显示从当前日期算起的过去 12 个月,因为维度和度量应该滚动过去 12 个月到该特定月份的 12 个月总和,即使这些月份未显示在维度值中。
例如,在 x 轴上,我们将拥有从 8 月 23 日到 7 月 24 日的数据。在 y 轴上,通知总数的显示方式应为 8 月 23 日的值应为从 9 月 22 日到 8 月 23 日数据的总和,即使 9 月 22 日未显示在 x 轴中。
以下给出的是我尝试过的事情:
Dimension : =If(Report_MonthYear >= monthstart(addmonths(today(),-12)) and Report_MonthYear <= monthstart(addmonths(today(),-1)),Report_MonthYear)
Measure :
RangeSum(Above(Count(distinct {<
Report_MonthYear -= { "$(='>=' & Date(AddMonths(TruncateMonth(Today()),-12),'MMM-YYYY'))<=' & Date(TruncateMonth(Today()),'MMM-YYYY')"} >} Notification),0,12))
您可以尝试一下这个功能:
Sum({<Report_MonthYear = {"$(='<=' & Today() & '>' & AddMonths(Today(),-12))"}>}
Aggr(
RangeSum(Above(Aggr(Sum(Notifications), Report_MonthYear), 0, 12)), Report_MonthYear
)
)
技巧在于,内部聚合
sum()
中没有考虑外部聚合RangeSum()
的集合表达式,因此我们可以计算一年前的月份,但只显示内部聚合中月份的结果去年。
这个文档非常有帮助。