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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
KMZ_ESS
Helper I
Helper I

Relative date "not in last 3 months"

Dear all,

 

I want to measure how many accounts of a certain category have not been visited in the last 3 months (using the field "last visit date"). The relative date filter allows to show the last 3 months, but I can't make it show entries with a date NOT in the last 3 months. If I use the advanced filter I can use the NOT operator, however the date range would be static and would not show the last 3 months with relation to the date of the query but a fixed 3 month range.

Is there a way to create the relative date filter with a NOT operator in a measure? Thanks a lot! 🙂

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

Hi  @KMZ_ESS ,

 

You can try the following measure:

Measure =
var _last3=DATE(YEAR(TODAY()),MONTH(TODAY())-3,DAY(TODAY()))
return
COUNTX(
    FILTER(ALL('Table'),
    'Table'[Date]>=_last3&&'Table'[Date]<=TODAY()&&'Table'[category]="A"),[Date])

 

Best Regards,

Liu Yang

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

6 REPLIES 6
joxieblue
New Member

add column: (Date) -> Age

Filter age greater than 120 days

v-yangliu-msft
Community Support
Community Support

Hi  @KMZ_ESS ,

 

You can try the following measure:

Measure =
var _last3=DATE(YEAR(TODAY()),MONTH(TODAY())-3,DAY(TODAY()))
return
COUNTX(
    FILTER(ALL('Table'),
    'Table'[Date]>=_last3&&'Table'[Date]<=TODAY()&&'Table'[category]="A"),[Date])

 

Best Regards,

Liu Yang

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

johnt75
Super User
Super User

The built-in functionality of the relative date filter is really lacking, there are a ton of improvement which could be made.

To get around it for your use case you could add a calculated column to your date table like

In Last 3 Months =
[Date] >= ( EOMONTH ( TODAY (), -4 ) + 1 )
&& [Date] <= TODAY ()

and then use that column as a filter.

This column flags items that are actually farther away than 3 months. Today is 6/14/2023, and per Google, 3 months before today was 3/14/2023. However, it returned "true" for a date of 3/3/2023.

Yes, this solution works in whole months. If you wanted partial months you could try something like

Date in last 3 months =
[Date] <= TODAY ()
    && [Date]
        >= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 3, DAY ( TODAY () ) )

Thanks a lot! Unfortunately, our security model doesn't allow users to add calculated columns. But thanks again for your suggestion! 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.