Posts

Showing posts from January, 2018

Showing the last 12 months based on a date slicer

Image
When working with financial and sales data, clients often ask for charts showing the last 12 months of data.  This is actually very simple using relative date filtering. In addition, they might ask to compare to the same month last year.  With a simple DAX calculation (SAMEPERIODLASTYEAR) it is possible to add this measure. Here is the formula: Same Month Last Year = CALCULATE(Sum(Sales[SalesAmount]),SAMEPERIODLASTYEAR('Date'[Datekey])) For many users this is all they need.  The chart will update each month and they will always be able to see the last 12 months.   However, this chart will not work with date slicers.   If the client adds a date slicer to the page and selects just one month, the chart will be limited to one month. The reason the chart is limited to one month is because the date dimension relates to the sales fact table and it filters the data for the selected month. However, this is not what