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
Sam7
Advocate II
Advocate II

How to filter out dates in the middle?

Hiya, 

 

I have a set of data, with dates from yesterday to the past.  I want to exclude the the day before yesterday and 9 days after this, so filter out this middle 10 days?  How do I action this?

 

Cheers

 

1 ACCEPTED SOLUTION
PijushRoy
Super User
Super User

Hi @Sam7 

Please write a Calculated Column with DAX function like 
Today date is 18.10.2023, so I made range of date as False

PijushRoy_0-1697568611371.png

 

 

Column = SWITCH(
    TRUE(),
    'Table'[Date] = TODAY()-1,"False",
    'Table'[Date] > TODAY()-11,"False",
    "True")

 

 

Then filter out your VIsual or Page with True or False value

You can write similar code in M Power Query

If solve your requirement, please mark as SOLUTION and give LIKE

View solution in original post

3 REPLIES 3
Sam7
Advocate II
Advocate II

Thank you

v-stephen-msft
Community Support
Community Support

Hi @Sam7 ,

 

You can create a custom column to filter.

=if [Date]>=Date.AddDays(DateTime.Date(DateTime.LocalNow()),-2) and [Date]<=Date.AddDays(DateTime.Date(DateTime.LocalNow()),7) then 1 else 0

vstephenmsft_0-1697706596679.pngvstephenmsft_1-1697706605390.png

Filter out 1, filter the middle 10 days.

vstephenmsft_2-1697706609492.png

Best Regards,

Stephen Tao

 

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

PijushRoy
Super User
Super User

Hi @Sam7 

Please write a Calculated Column with DAX function like 
Today date is 18.10.2023, so I made range of date as False

PijushRoy_0-1697568611371.png

 

 

Column = SWITCH(
    TRUE(),
    'Table'[Date] = TODAY()-1,"False",
    'Table'[Date] > TODAY()-11,"False",
    "True")

 

 

Then filter out your VIsual or Page with True or False value

You can write similar code in M Power Query

If solve your requirement, please mark as SOLUTION and give LIKE

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.

Top Solution Authors
Top Kudoed Authors