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

Future Date Filtering

Hi,

 

Im looking for some help with creating a filter to apply to my report.


I have a field called DUEDATE and i want to filter my report results to show only where the DUEDATE is in the next 3-6 months.

 

For example if today is 28/10/2020 i want the report to only show due dates that are due in the next 3-6 months so from 28/01/21 to 28/04/21

 

I have created one report already which was a report that only shows DUEDATE in the next 3 months which i used the relative date filter (easy enough) but its the 3-6 month and 6-12 month reports im finding difficult.

 

Any help would be apprechiated

 

Thanks

 

Alex

1 ACCEPTED SOLUTION

Hi @Anonymous ,

As my previous note in the formula, you can use today() function to replace the specific date in the formula:

Measure = 
IF (
    SELECTEDVALUE ( 'Table'[Date] ) >= EDATE ( TODAY(), 3 )
        && SELECTEDVALUE ( 'Table'[Date] ) <= EDATE ( TODAY(), 6 ),
    1,
    0
)

Result:

VC.png

 

Best Regards,
Community Support Team _ Yingjie Li
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

9 REPLIES 9
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can try to use EDATE() function to create a control visual measure, set its value as 1 and put it in the visual filter:

Measure =
IF (
    SELECTEDVALUE ( 'Table'[Date] ) >= EDATE ( DATE ( 2020, 10, 28 ), 3 )
        && SELECTEDVALUE ( 'Table'[Date] ) <= EDATE ( DATE ( 2020, 10, 28 ), 6 ),
    1,
    0
)
// the date in the edate() function can be any and today(), depends on your need, this is just an example

vf.png

Attached a sample file in the below, hopes to help you.

 

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

Anonymous
Not applicable

Hi, Thanks for this.

 

This is working and when i apply the filter to equal '1' it is showing the dates that are 3-6 months from 28/10/20.


Instead of inputting a specific date into the EDATE how would i apply the date to just be TODAY as this would then constantly change the filter everyday as i would like this to be used for a long time so as a tender expected date ages it moves from 0-3, 3-6, 6-12 so on and so forth.

 

Basically how do i get the date to just be from today instead of 28/10/20.

 

Thanks very much for your help this has been frustrating to get the right solution

 

Alex

Hi @Anonymous ,

As my previous note in the formula, you can use today() function to replace the specific date in the formula:

Measure = 
IF (
    SELECTEDVALUE ( 'Table'[Date] ) >= EDATE ( TODAY(), 3 )
        && SELECTEDVALUE ( 'Table'[Date] ) <= EDATE ( TODAY(), 6 ),
    1,
    0
)

Result:

VC.png

 

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

Anonymous
Not applicable

Thanks very much. I think this is now working exactly how i need it to. Out of curiosity how does the measure know to choose the month and not the day or year?

Also i can use the same measure to create another filter for date in the next 6-12 and 12-18 just by copying this measure and changing the 3 and the 6 to 6 and 12?

Thanks

Alex

Hi @Anonymous ,

"Out of curiosity how does the measure know to choose the month and not the day or year?"

This is how EDATE() works, it returns the date that is the indicated number of months before or after the start date. You can refer my first post link about this function which introduces it in details.

 

"Also i can use the same measure to create another filter for date in the next 6-12 and 12-18 just by copying this measure and changing the 3 and the 6 to 6 and 12?"

If the date is not above the power bi limitatio, you are right.

 

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

Anonymous
Not applicable

Hi,

I have just applied the following mesure for 12-36 months and it doesnt seem to be working. Does this have a limit on what months it can go from and to? Capture2.PNG

Anonymous
Not applicable

Thanks very much this works perfect

amitchandak
Super User
Super User

@Anonymous , Try like

measure =
var _max1 = maxx(allselected(Date),Date[Date])
var _max = date(year(_max1), month(_max1)+6, day(_max1))
var _min = date(year(_max1), month(_max1)+3, day(_max1))
return
calculate([Measure],filter(Date, Date[Date] >=_min && Date[Date] <=_max))

Anonymous
Not applicable

Hi @amitchandak ,

 

Thanks for your reply.

 

I was recieving errors below where its highlighted in bold:-

 

measure =
var _max1 = maxx(allselected(Date),DUEDATE[DATE],
var _max = date(year(_max1), month(_max1)+6, day(_max1))
var _min = date(year(_max1), month(_max1)+3, day(_max1))
return
calculate([Measure],filter(Date, Date[Date] >=_min && Date[Date] <=_max))

 

 

 
 

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.