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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AllanBerces
Post Prodigy
Post Prodigy

Dynamic Date Filter

Hi good day can anyone help me on my PQ, i want to filter the date before the lates date dynamically. Base from below table i want to filter the date 6/26. by next week or next month the 8/7 if i have a lates data.

AllanBerces_0-1754975973025.png

 

Thank you

3 ACCEPTED SOLUTIONS

Hello @AllanBerces 

 

let
Source = YourPreviousStep,
SortedDates = List.Sort(List.Distinct(Source[Date modified]), Order.Ascending),
LatestDate = List.Last(SortedDates),
PreviousDate = List.LastN(SortedDates, 2){0},
FilteredRows = Table.SelectRows(Source, each [Date modified] = PreviousDate)
in
FilteredRows

View solution in original post

mdaatifraza5556
Super User
Super User

Hi @AllanBerces 


1.   Sort your date column in Descending order ( To sort right click on column and choose descending option)

2.  Then click on add steps and use thi below M code
      #"Sorted Rows"{1}[Date modified] -------------------------------//#"Sorted Rows" this is the prev steps Name

 

Screenshot 2025-08-12 120754.png

 

 

 

you get the List 

 

Screenshot 2025-08-12 120802.png

 

 

Now convert the list into table (you can see upper left side there is option to convert the list to table

Screenshot 2025-08-12 120817.png

 

 

 

Here is the result

 

Screenshot 2025-08-12 120826.png

 

 

If this answers your questions, kindly accept it as a solution and give kudos.

View solution in original post

Dilpreeth_CAT
Regular Visitor

Step 1: Sort the date column in descending order

Step 2: Add index column starting from 1

Dilpreeth_CAT_0-1754981695908.png

Step 3: Filter on index column for value = 2

 

View solution in original post

6 REPLIES 6
Dilpreeth_CAT
Regular Visitor

Step 1: Sort the date column in descending order

Step 2: Add index column starting from 1

Dilpreeth_CAT_0-1754981695908.png

Step 3: Filter on index column for value = 2

 

Hi @Dilpreeth_CAT @mdaatifraza5556 @pankajnamekar25 thank you very much for the reply all good and working asi need.

mdaatifraza5556
Super User
Super User

Hi @AllanBerces 


1.   Sort your date column in Descending order ( To sort right click on column and choose descending option)

2.  Then click on add steps and use thi below M code
      #"Sorted Rows"{1}[Date modified] -------------------------------//#"Sorted Rows" this is the prev steps Name

 

Screenshot 2025-08-12 120754.png

 

 

 

you get the List 

 

Screenshot 2025-08-12 120802.png

 

 

Now convert the list into table (you can see upper left side there is option to convert the list to table

Screenshot 2025-08-12 120817.png

 

 

 

Here is the result

 

Screenshot 2025-08-12 120826.png

 

 

If this answers your questions, kindly accept it as a solution and give kudos.

pankajnamekar25
Super User
Super User

Hello @AllanBerces 

Try this M code

let
Source = YourPreviousStep,
LatestDate = List.Max(Source[Date modified]),
FilteredRows = Table.SelectRows(Source, each [Date modified] = LatestDate)
in
FilteredRows

 

the latest date is 6/26, it keeps only 6/26 rows.

Next week or month, if the latest date changes (e.g., 8/7), it will auto-update.

 

Hi @pankajnamekar25 thank you for the reply, but the required date i need to filter is not the lates date, the previous date. on my table i have the lates date of 8/7. i need to filter the 6/26 

Hello @AllanBerces 

 

let
Source = YourPreviousStep,
SortedDates = List.Sort(List.Distinct(Source[Date modified]), Order.Ascending),
LatestDate = List.Last(SortedDates),
PreviousDate = List.LastN(SortedDates, 2){0},
FilteredRows = Table.SelectRows(Source, each [Date modified] = PreviousDate)
in
FilteredRows

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors