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.
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.
- Anonymous9 years agoNot applicable
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
- Anonymous8 years agoNot applicable
Dear Anonymous,
Have you try What-If parameter?
You can create new Parameter type Number, it'll use for selected number and refresh data with last 1,2,3,....9 month.
Parameter Value = SELECTEDVALUE(Parameter[Parameter], 3)
Then make measure, filter it by some Operation with "Parameter Value".
Topic about Parameter: https://powerbi.microsoft.com/en-us/blog/power-bi-desktop-august-2017-feature-summary/#whatIf
If you need a day drill option, you can use Custom Visual "TimeBrush". You can drag mouse to select a range or move it.