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
jhowe
Regular Visitor

Filter Dates to only show current month and next 12 months

I am trying to create a more dynamic date filter for a report of mine that shows past and predicted data. I would like a filter that only shows data related to the current month and the12 months to follow. For example from June 2016 to June 2017. But I would like BI to be able to recognize what the current month is so that when the next month begins it can automatically adjust the filter. Meaning that when June ends I would like BI to automatically adjust the filter to show July 2016 to July 2017. I would really appreciate any help or ideas people have. I have attached an image of my current table. BITable.PNG

 

Thanks, 

James 

3 ACCEPTED SOLUTIONS
jahida
Impactful Individual
Impactful Individual

Hi,

 

PowerBI has filtering wizards, so I could provide you with M code but I think it's more useful for you if I show the process for using the wizard:

 

I'm using a dataset of mine, with a date column. Click on the down arrow with the column header:

Capture.PNG

 

Then go to Date/Time filters -> In the Next...

 

That should open up a window where you can select these options:

 

Capture2.PNG

And

 

 

View solution in original post

felyoubi
Resolver I
Resolver I

Hi,

 

You have two ways in doing this, M or DAX. I prefer the latter because it is straightforward and it doesn't require refresh of the data model. Here we go:

 

DAX:

Current Month = IF(MONTH(DimDate[Date])=Month(NOW()), "Current Month", Format([Date], "YYYY mmmm"))

Select a slicer and sort by date, this will make sure it puts Current Month always on top.

 

M:

= Table.AddColumn(MonthName, "CurrentMonth", each Date.IsInCurrentMonth( [Date] ))

 

Regards,

Fahd

View solution in original post

CheenuSing
Community Champion
Community Champion

@jhowe

 

I assume that you want to show the current and future Sales for the next 12 months in a chart.

 

Try the following

 

1. I am assuming you have a date table

2. Create a Column in the date table  called as MonthSequentialNumber as

     MonthSequentialNumber = year( date in date table ) * 12 + Month( date in date table) - 1

     This will create a unique number for each combination of month and year.

3. Create a measure called CurrentMonthSeqeuntialNumber = Year(Today()) * 12 + Month(today()) - 1

    This will find the MonthSequentialNumber based on todays date. 

4. Create a column in Date table called Show as

      Show = IF (
                          [MonthSequentialNumber ] >= [CurrentMonthSeqeuntialNumber ] &&

                          [MonthSequentialNumber ] <= [CurrentMonthSeqeuntialNumber ] + 11, 1, 0
                          ) 

5. Show will  have a value of 0 or 1 in the date table.

6. Assume you have a measure called [Sales] that calculates the sum of Sales . As per your requirment I am assuming your sales records contains future predicted sales.

7. Create a bar chart  where x-axis is Month and Y- axis is Sales measure.

8. In the visual level filter for the bar chart drag the field Show and set the filter condition show items when the value is 1.

9. You will then be able to see the Sales for the current month and the future 12 months from Now.

 

Should you require further assistance , please do not hesitate to reply to this post.

 

If this works for you please accept it as a solution and also give kudos.

 

Cheers

 

CheenuSing

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

15 REPLIES 15

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.