March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi - is it possible in Powerquery to create a column alongside a date column that does the following...
Today is 17th May - make record state "This Month"
Previous date say 15th April would need to state "Last Month"
Month before that say 15th March would then say "Last Month +1"
The file is constantly being updated and I need to create measures using "This Month" etc..
I am only going to do this for 6 monthly points anything before will get ingored so easy enought to code it in I guess...
Thanks 🙂
Solved! Go to Solution.
I have managed to create a flag for "This Month" but need to add a "Last Month" & "Previous Month" & "Previous Month +!" etc etc - just 6 times anything out of date range I can 'Else' out
if Date.StartOfMonth([date]) = Date.StartOfMonth(DateTime.Date(DateTime.LocalNow())) then "This Month" else "Not this month"
Thats did it - thanks very much for your suggestion it worked. Thanks
Try this, you can jsut repeat the last else if until you get the desiered number of months (I only went to Last Month +1)
= Table.AddColumn(#"Changed Type", "MonthCheck", each
if Date.StartOfMonth([Date]) = Date.StartOfMonth(DateTime.Date(DateTime.FixedLocalNow()))
then "This Month"
else if Date.StartOfMonth([Date]) = Date.StartOfMonth(Date.AddMonths(DateTime.Date(DateTime.FixedLocalNow()),1))
then "Next Month"
else if Date.StartOfMonth([Date]) = Date.StartOfMonth(Date.AddMonths(DateTime.Date(DateTime.FixedLocalNow()),-1))
then "Last Month"
else if Date.StartOfMonth([Date]) = Date.StartOfMonth(Date.AddMonths(DateTime.Date(DateTime.FixedLocalNow()),-2))
then "Last Month + 1"
else "Check")
Yes, that is possible - as long as you refresh this in import mode frequently (daily)
HI yes it reloads a number of times per day and every day so should be able to use Today()
I have managed to create a flag for "This Month" but need to add a "Last Month" & "Previous Month" & "Previous Month +!" etc etc - just 6 times anything out of date range I can 'Else' out
if Date.StartOfMonth([date]) = Date.StartOfMonth(DateTime.Date(DateTime.LocalNow())) then "This Month" else "Not this month"
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.