Here is a handy trick to calculate last day of any month.
Assuming y and m contain the year & month for which you want to find the last day’s date, write
=DATE(y, m+1,0)
That is right, you can use ZERO (0) as the day.
When you do this, Excel tells us the last day of previous month.
How to calculate last day if I have a date in that month:
Instead of year and month, if you know a date & you want to find what is the last date… then use:
=EOMONTH(date, 0)
How to calculate the last working day of a month?
If you just care about working days.. then use:
=WORKDAY(DATE(y,m+1,1), -1)
This will give us the last working day of a month.
Dealing with holidays:
Very simple. Pass on a list of holidays to WORKDAY as last parameter. Like this:
=WORKDAY(DATE(y,m+1,1), -1, F1:F20)
This assumes, F1:F20 has a list of holiday dates.
Dealing with different weekend types:
Not everyone observes Saturday & Sunday as weekend. For example, I do not work on Tuesdays. You might have Sunday thru Thursday work week. If so,
use WORKDAY.INTL function, like this:
=WORKDAY.INTL(DATE(y,m+1,1), -1, 7)
Weekend type 7 is for Friday & Saturday weekend.
How do you calculate last date of a month?
Do you use some other formula to do this? Please share your tip using comments.
Work with dates often?
If you work with dates, then spend some time reading these tips:
















10 Responses to “Multiple Find Replace with Power Query List.Accumulate()”
Note: The text-formula above miss a -1. The video is correct.
😀 sorry, I made the exact same mistake as you did - initially - in the video. {0..3} is one thing, and Table.RowCount(replacements) -->3 items ={0,1,2} is another thing.
1st question : you've created a new column to put the replacements in. how ca we replace in the original column without creating a new one ?
2nd question : how can we replace the value in the entire cell and not only the text (Using ReplaceValue instead of text.Replace) ?
Thanks you in advance
Chandoo, I would be very interested to have your answers in both Yassine's questions!
Thank you for sharing,
Vassilis
Thank you for this! I was just doing an assignment where I was having to replace words with other words in my Excel sheet. We are starting with the basics in my class, so I know I don't have a huge list that I would need to find and replace, but this is something that could be useful down the road for me!
Hi
This is nearly perfect for my needs thank you, however I would like just the "replace" to be the result if possible please, I have tried in vain adjusting the formula without success.
Thank you in advance
Thank you! Awesome tip, and very flexible, too.
My find/replace values were in non-adjacent columns of a table containing a bunch of other data. Worked prefectly and I am now a tiny bit less clueless.
Hi!!!
I have the same question that Yassine did.
I need to replace the values in the same column. I don't want to create a new column e then have to remove the old column.
How could I could that?
That's a real fun article. It inspired me to delve deeper into the topic of List.Accumulate. I can see how the function works, but it takes an additional step to imagine how one can use it for more complex applications.
Your example also made it into my article, together with some other use-cases. Would be great to get your opinion on which other areas you would include in the article.
Let me drop the link to the page so others can too find it for further reading: https://gorilla.bi/power-query/list-accumulate/
Expression.Error: The name 'replacements' wasn't recognized. Make sure it's spelled correctly.