Override Slicer Filter Context in Chart (To Show Fuller X-Axis)

天大地大妈咪最大 提交于 2019-12-25 02:29:11

问题


Imagine I have a fact table with sales spanning 3 years (2016-2018). I have a chart showing sales by month (36 points on the X-Axis). I have a slicer selection to Year = 2018, and Month = June.

Is it possible, with a measure, to show on a chart, the trailing 6 months from the slicer selection? In other words, with the slicer still set to Year = 2018 and Month = January, can the chart display 6 points (the trailing 6 months)?

How would this be accomplished?


回答1:


The approach I would use in this case would be to create a parameter table for the date which doesn't have a relationship with my other tables and use that date for the slicer. Then you'd write the sales measure you use on the chart to read the selected date and return blanks for any dates not within the range you want.

Roughly like this:

NewSalesMeasure = 
    VAR SelectedDate = SELECTEDVALUE(Slicer[Date])
    VAR CurrentDate = SELECTEDVALUE(Sales[Date])
    RETURN IF(CurrentDate <= SelectedDate &&
              CurrentDate > DATEADD(SelectedDate, -6, MONTH)
              SUM(Sales[Amount]),
              BLANK()
           )


来源:https://stackoverflow.com/questions/51994545/override-slicer-filter-context-in-chart-to-show-fuller-x-axis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!