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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Conditional Filtering

Hello everyone,

 

I got this [Date] column and I would like to filter it but conditionally, if today is Monday so I need it to filter [Date] to keep only Sunday’s, Saturday’s and Friday’s entries that preceded today only, otherwise, to filter [Date] to keep only yesterday’s entries, how to do that?

 

Another question related to data models in excel, is there a way to load them in tables, not power pivot?

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Add a new blank query and go to the advanced editor. Delete all the code and paste this in:

let
    Source = if Date.DayOfWeek(DateTime.LocalNow(), Day.Monday) = 0 then Date.AddDays(DateTime.Date(DateTime.LocalNow()), -3) else Date.AddDays(DateTime.Date(DateTime.LocalNow()), -1)
in
    Source

If today is Monday, it will return a day 3 days in the past, otherwise 1 day in the past.

Call this query varDate. Set it not to load.

 

Now, go to your data and filter for any day to get the filter to work. Remove whatever date you selected (it might say #date(2022,3,25) - remove that code and use varDate.

It might look like this:

Table.SelectRows(#"Added Custom", each ([Dates] = varDate))

On the 2nd question, no. You can create a flat pivot table, but not a pure table. Those must come direclty from Power Query, not Power Query to Power Pivot then down to and Excel sheet.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

1 REPLY 1
edhans
Super User
Super User

Add a new blank query and go to the advanced editor. Delete all the code and paste this in:

let
    Source = if Date.DayOfWeek(DateTime.LocalNow(), Day.Monday) = 0 then Date.AddDays(DateTime.Date(DateTime.LocalNow()), -3) else Date.AddDays(DateTime.Date(DateTime.LocalNow()), -1)
in
    Source

If today is Monday, it will return a day 3 days in the past, otherwise 1 day in the past.

Call this query varDate. Set it not to load.

 

Now, go to your data and filter for any day to get the filter to work. Remove whatever date you selected (it might say #date(2022,3,25) - remove that code and use varDate.

It might look like this:

Table.SelectRows(#"Added Custom", each ([Dates] = varDate))

On the 2nd question, no. You can create a flat pivot table, but not a pure table. Those must come direclty from Power Query, not Power Query to Power Pivot then down to and Excel sheet.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Kudoed Authors