Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi I would like to create filter which allows me to select the last week of data or the last month or the last quarter. My Visual is laid as per the below image.
I do have a date table which has weeknumber,month number etc...
Solved! Go to Solution.
Hi @Anonymous ,
You could simply select the slicer type as "Relative Date":
Or create a new table for slicer:
Then try the following formula to create a measure:
Measure =
var _week = IF(DATEDIFF(MAX('Table'[Week End]),TODAY(),WEEK)=1,1,0)
var _month= IF(DATEDIFF(MAX('Table'[Week End]),TODAY(),MONTH)=1,1,0)
var _quarter=IF(DATEDIFF(MAX('Table'[Week End]),TODAY(),QUARTER)=1,1,0)
return SWITCH(MAX('ForSlicer'[Type]),"Last Week", _week,"Last Month",_month,"Last Quarter",_quarter)
Last, apply the measure to filter pane, set as "=1":
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
You could simply select the slicer type as "Relative Date":
Or create a new table for slicer:
Then try the following formula to create a measure:
Measure =
var _week = IF(DATEDIFF(MAX('Table'[Week End]),TODAY(),WEEK)=1,1,0)
var _month= IF(DATEDIFF(MAX('Table'[Week End]),TODAY(),MONTH)=1,1,0)
var _quarter=IF(DATEDIFF(MAX('Table'[Week End]),TODAY(),QUARTER)=1,1,0)
return SWITCH(MAX('ForSlicer'[Type]),"Last Week", _week,"Last Month",_month,"Last Quarter",_quarter)
Last, apply the measure to filter pane, set as "=1":
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is quite cool, first option is not doable for me as baseg in UK and week start/end isnt correct ISO standard, Mon-Sun. Your second option works but need Date on the visual ?
@Anonymous , as last week and last month are overlapping. You can not do that in date table.
You have to create an independent table with these values and then using these values you have to create a measure, just like measure slicer
measure slicer
https://www.youtube.com/watch?v=b9352Vxuj-M
https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/500115
Another example that can help
Power BI Abstract Thesis: Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE
What is the DAX if I am looking for LAST MONTH - not MTD. Example - it is Oct.2.2023 and I need last Month (Calendar) 9.1-9.30. I do not want weeks or days so Relative slicer does not meet my requirements.
Thanks!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
84 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |