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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
ValeriaBreve
Post Partisan
Post Partisan

Logic based on dates interaction in PowerQuery

Hello!

I need to run a specific logic in one of my queries.

I have a column coming from the database: "Last Updated On" which is the last time the users sent the data modifications to the database.

And then I have a column "Activity Start Date", with date and time of when the activity will start.

The logic is that the activity start date should be classified as "Include" only if:

1) the Activity Start Date is greater than the corresponding "Last Updated On" (this is the easy part ;-)) AND

2) the Activity start date is smaller than the next "Last Updated On" in chronological order.

 

I have tried to summarize below:

 

ValeriaBreve_0-1678104098928.png

 

Could you please help me to understand how to reach the second condition?

 

Thanks!!!!

Kind regards

Valeria

1 ACCEPTED SOLUTION
ValeriaBreve
Post Partisan
Post Partisan

I think I figured this one out... I added a ranking column on the table on the Last Updated On Column (Table.AddRankColumn(#"Filtered Rows1","Rank",{"LAST_UPDATED_ON", Order.Ascending},[RankKind = RankKind.Dense])

 

Then, I duplicated the query, grouped by "Last Updated On" date and "Rank", and then added a custom column "Rank -1". I then merged this query with the original one on the Rank/Rank-1 column to get the next available "Last Updated On" date, from here it's easy.

 

Please chime in if you have a better solution!

 

Thanks

Kind regards

Valeria

View solution in original post

1 REPLY 1
ValeriaBreve
Post Partisan
Post Partisan

I think I figured this one out... I added a ranking column on the table on the Last Updated On Column (Table.AddRankColumn(#"Filtered Rows1","Rank",{"LAST_UPDATED_ON", Order.Ascending},[RankKind = RankKind.Dense])

 

Then, I duplicated the query, grouped by "Last Updated On" date and "Rank", and then added a custom column "Rank -1". I then merged this query with the original one on the Rank/Rank-1 column to get the next available "Last Updated On" date, from here it's easy.

 

Please chime in if you have a better solution!

 

Thanks

Kind regards

Valeria

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.