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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
abriggs
Frequent Visitor

End of Month in Power Query

I need help with M code to do this in Power Query. The customer account balance table creates an entry every day whether the customers balance has changed or not (resulting in multiple duplicate entries). This is helpful when viewing the aging trend day by day....but not helpful when I need to view it by month. Therefore, I want to insert a column that will insert the total balance due if the balance date is the end of the month else insert 0. I'm not very familiar with M Code so I'm unsure how to do this. the code that I've written is this, but it's just returning with all 0's. 

 

if [BalanceDate]=Date.EndOfMonth then [TotalBalanceDue] else 0 

 

Assuming I'm not using the EndOfMonth properly? 

 

Please help or if there is a better solution to get around this I'm open to that as well. 

 

Thank you so much!  

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @abriggs 

Try

if [BalanceDate]=Date.EndOfMonth([BalanceDate]) then [TotalBalanceDue] else 0 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

Hi @abriggs 

Try

if [BalanceDate]=Date.EndOfMonth([BalanceDate]) then [TotalBalanceDue] else 0 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

abriggs
Frequent Visitor

Thank you - this worked! 

 

Looking to take it one step further and add...if it's not end of the month in the current month, then total for that month as of today. So example, since we haven't hit end of month for October, I'd like it to pull through the balance for today instead of 0. 

 

Thoughts? Thank you 🙂 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors