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

The Fabric community is upgrading! Read all of the details including the timeline and what you can expect. Learn more

Reply
Anonymous
Not applicable

Custom Column Power Query

Hi Experts

 

need a custom column to do the following if the date is current month -1 then "Actual" ie. Feb 21 and all historical months in year and any future period then return "4YOP".

 

 

1 ACCEPTED SOLUTION

@Anonymous , you have shared your formula. I copy passed same in my file and changed the date and it worked , only in bold need to be changed

if [Sales Date] >= Date.StartOfMonth(Date.AddMonths(Date.From(DateTime.LocalNow()),-1)) and [Date] <= Date.EndOfMonth(Date.AddMonths(Date.From(DateTime.LocalNow()),-1))
then "Actual" else "4YOP"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Try a new column like

 

if [Date] >= Date.StartOfMonth(Date.AddMonths(Date.From(DateTime.LocalNow()),-1)) and [Date] <= Date.EndOfMonth(Date.AddMonths(Date.From(DateTime.LocalNow()),-1))
then "Actual" else "4YOP"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Getting an error here "Actual" - message Token Eof expected? - or alternatively on then

@Anonymous , you have shared your formula. I copy passed same in my file and changed the date and it worked , only in bold need to be changed

if [Sales Date] >= Date.StartOfMonth(Date.AddMonths(Date.From(DateTime.LocalNow()),-1)) and [Date] <= Date.EndOfMonth(Date.AddMonths(Date.From(DateTime.LocalNow()),-1))
then "Actual" else "4YOP"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Apologies my fault... i had IF as opposed to if.... thanks Amit

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.