Forum Discussion
Last N Months
Hello Team,
I have a bar chart with date on x-axis and profit on y-axis. The requireent is to have the buttons on top like "Last 1 Month", "Last 2 Months" and "Last 6 Months" as shown in attached screenshot.
When I click on the tab 'Last 1 month' then the graph should be plotted for last 30 days. When I click on the tab "Last 2 Months" then the graph should be plotted for last 60 days. Similarly for last 6 months.
Note: As per my analysis, this can be acheived thru bookmarks (show/hide charts as per text button selection).
Also the same can be achieved thru what-if parameter. But users have suggested to make it dynamic with buttons and one chart.
.pbix file here
https://1drv.ms/u/s!ArRkjWtfVLy-bH0zanIVQBIK1u4
screenshot here
- Anonymous5 years ago
Hi BSM1985 ,
I just updated your sample pbix file, please check if that is what you want. You can get the updated file from this link.
Best Regards
Rena
4 Replies
- Greg_Deckler
Community Champion
BSM1985 You can do this with a column in your table where you flag items last 2 months, etc. Otherwise, you can do it in a measure like:
Measure = VAR __Selected = MAX('Slicer'[Value]) VAR __Calc = <some calculation> RETURN IF(MAX('Date'[Date]) < TODAY() && MAX('Date'[Date])>=DATE(YEAR(TODAY()),MONTH(TODAY()),1),__Calc,BLANK())As an example.
- amitchandak
Super User
BSM1985 , Very similar stuff was discussed in this ticket see if that can help . https://community.powerbi.com/t5/Desktop/Required-custom-date-Slicer-Last-7-days-last-15-days-last-30/m-p/1284966#M561629
But use an independent date table. Other data can group on a single date refer:https://www.youtube.com/watch?v=duMSovyosXE
- AnonymousNot applicable
- BSM1985
Helper IV
Thanks a lot Anonymous Greg_Deckler amitchandak for all your help.