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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
game1
Helper III
Helper III

Filter date for the last 7days

Hello!
I would like to create a new column to filter the TABLE[Date] which is in YYYY-MM-DD HH:mm:ss format, so that it just returns me the list of the last 7 days when I choose the box last7days,  I would have only the dates of the last 7 days and for the list of the last 30 days,  I would have only the dates of the last 30 days.

So, I want 2 box: 

last7days

last30days


THANKS.

3 REPLIES 3
game1
Helper III
Helper III

Not functionnig. I try this:

datesDiff = if(datediff(Table[Date], Today(), DAY) <=7, "7 last days", "more than 7 days") but I dotn have the good range. For example, from today, it's supposed to return me the lsit of date beetween 2023-12-07 to 2023-12-13. Where is the problem? Do I have other option? Thanks! 

Greg_Deckler
Super User
Super User

@game1 I would add an offset column to your data which is the number of days from today. So, for example, start with today being 0 and it increments up from there. Then you could build a simple measure that filters for <=7 and <=30. Can be done in Power Query or DAX. Here is the DAX version:

Sequential - Microsoft Fabric Community



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I use datesDiff =
SWITCH(
TRUE(),
Table[Date] >= TODAY() - 7 && Table[Date] < TODAY(), "7 last days",
Table[Date] >= TODAY() - 30 && Table[Date] < TODAY(), "30 last days",
TRUE(), "more than 30 days"
)

but, it is only give the good range for the first one (7 last days). For the other, the range are not good. Why? How correct that?

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.