Forum Discussion
Last 3 Months Slicer
When i need to filter last periods i usually add a column in dax like this:
DateFilter = IF(Sales[Date] >= DATE(YEAR(DATEADD(LASTDATE(ALL(TableDate[Date])) , -4 , MONTH)),
MONTH(DATEADD(LASTDATE(ALL(TableDate[Date])) , -4 , MONTH)),
1),
"Last four months",
IF (AND(
YEAR(Sales[Date]) = YEAR(NOW()),
MONTH(Sales[Date]) = MONTH(NOW())
),
"Last month",
"More than 4 months"
)
With the logic you can add different ways. The example contains last 4 months and last month.
Regards,
P/D I hope the DAX is okay I didn't have time to run it.
- JakubHa9 years agoFrequent Visitor
Hi ibarrau,
the problem is my periods can overlap each other.
I would like to have last month, last 3 months, last 6 months and overall. I think tough your formula won`t apply there :(
- ibarrau9 years ago
Super User
Did you try the relative date slicer of the new release of power bi? It is a preview feature you have to activate in power bi desktop. That is the only aproach to have only one column specify as you need.
You can read more in the release notes:
https://powerbi.microsoft.com/en-us/blog/power-bi-desktop-may-feature-summary/#relativeDateSlicer
Regards, hope this help or you may need more columns I think.
- JakubHa9 years agoFrequent Visitor
Yes, it`s working acceptably but I wanted to build more flexible slicer based on data I am providing. For instance, no day drill option when I have only month-based data. By relative date slicer it`s not possible.
thank you for your ideas anyway!
Jakub