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
HakamAbushanab
Regular Visitor

Power Query - Excluding current month

ee.pngIn the pursuit of precise and truthful data visualization, it sometimes becomes necessary to omit partial data that may not offer a complete picture. A common scenario where this practice is applicable is the representation of data for the current month, which is often not complete and can skew the comparison with the same period from the previous year.

To address this, we can strategically exclude the current month's data from our visualizations, thus enabling a more accurate year-over-year comparison. Leveraging the capabilities of Power Query M, we can accomplish this through the following script, applied to a field labeled “Date”:

= Table.SelectRows(#"Renamed Columns5", each not (Date.Year([Date]) = Date.Year(Date.From(DateTime.LocalNow())) and Date.Month([Date]) = Date.Month(Date.From(DateTime.LocalNow()))))

This script dynamically filters out the records pertaining to the current month, ensuring that our visualizations are both truthful and insightful, untainted by incomplete data.

Feel free to reach out with questions or to discuss this strategy further. Your feedback and insights are highly valued as we continue to refine our data representation methods. : )

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

 

Or, more simply:

Table.SelectRows(PreviousStep, each not Date.IsInCurrentMonth([Date]))

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

 

Or, more simply:

Table.SelectRows(PreviousStep, each not Date.IsInCurrentMonth([Date]))

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Great job Pete, it is brand new function. According to the Power Query M documentation: https://learn.microsoft.com/en-us/powerquery-m/date-isincurrentmonth, the Date.IsInCurrentMonth function was created on July 19, 2023.

 

No, that was the date the article was last updated.

Date.IsInCurrentMonth has been in the M language spec for many years.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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!

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