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
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
Super User
Super User

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.


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

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