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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Limit to N months displayed on a Sales by Month bar chart

Trying to build a simple bar chart say Sales by months.

  1. ideally only display a fixed number of months (Say 12 months only even if the data contains more months data)
  2. ideally only display a fixed number of months from CURRENT month (no hard coding)

Any advice on the best practice to implement this?

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

You should be able to use a technique similar to:

 

DaysPast = DATEDIFF([Date],TODAY(),DAY)

DATEDIFF will also take "MONTH" in the last parameter. Then you can just set the filter to something like DaysPast > 30 days or 12 months for example.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I am tackling a similar scenario but for some reason, I am having some problem and I am not able to figure out the solution

 

In a table, I am having a column with the date. I have only 6 months of Date and data in the table.

 

When I pull the column to a slicer, it shows the first date and last date correctly where as when I pull the date to a table, it lists all the months. Is this a bug?

 

I want to calculate the number of months I have selected, but the measure always ends up showing 12 instead of 6.

 

The measure I am using is 

 

CountOfMonths = DATEDIFF(FIRSTDATE(Table1[SampleDate].[Date]),
    LASTDATE(Table1[SampleDate].[Date]),MONTH)

 

image.png

Anonymous
Not applicable

Thanks for that. It does work.

 

The only problem is that it hard coded to be today() which is current day/month. In reality, users want to be able to do from a selected / specified month (EG from a slicer). In the other words, can we do past N months from current SELECTED month instead of current month? 

@Anonymous

 

According to your description, it seems that you're looking for a date range slicer. There's already one official customized The Timeline Slicer.

You can download the visualization and sample from here.

 

Capture.PNG

 

There is a feature request that will enable users to make an offset to time intelligence - please vote if you think it will satisfy your needs.

 

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/13805892-time-intelligence-base-t...

 

/sdjensen

Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.