Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
BSM1985
Helper IV
Helper IV

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

Tabs1.PNG

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

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.

Last N months.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

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.

Last N months.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks a lot @v-yiruan-msft @Greg_Deckler @amitchandak  for all your help.

Greg_Deckler
Super User
Super User

@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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
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-3...

 

But use an independent date table. Other data can group on a single date refer:https://www.youtube.com/watch?v=duMSovyosXE

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.