Quantcast
Channel: Power Query topics
Viewing all articles
Browse latest Browse all 31099

Get the first day of the next month/quarter/year

$
0
0

I would like to get a the first day of the next month/quarter/year if a date is not on the start day of that period in Power BI. So I made the following custom column in M, based on an interval and the date. The interval for monthly is 1, quarterly is 3 and annually is 12. I seem to have som issues with and/or, because with the input date of 1 October 2024 (the start of the last quarter) it returns 1 January 2025 instead of 1 October 2024. Could you please help me finding out what I'm doing wrong? 

 

 

if [interval] = 1 and Date.Day([date]) <> 1 then Date.AddMonths(Date.StartOfMonth([date]), 1) else if [interval] = 3 and ( Date.Day([date]) <> 1 or Date.Month([date]) <> 1 or Date.Month([date]) <> 4 or Date.Month([date]) <> 7 or Date.Month([date]) <> 10 ) then Date.AddMonths(Date.StartOfQuarter([date]), 3) else if [interval] = 12 and ( Date.Day([date]) <> 1 or Date.Month([date]) <> 1 ) then Date.AddYears(Date.StartOfYear([date]), 1) else [date]

 

 


Viewing all articles
Browse latest Browse all 31099

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>