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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Narenthir
Frequent Visitor

Power Query

Hi,

Below pic from excel, the similar way i want to do in power bi, spceific date before need to reflect as (base) after the dates should be reflect as (After). Help needed thank in advance.

Narenthir_0-1679982756754.png

 

1 ACCEPTED SOLUTION
ChielFaber
Solution Supplier
Solution Supplier

When you use a specific date you can use a hardcoded date. For this you can create a custom column with the folloewing if statement and the #date function:

if [Date] < #date(2023, 3, 1) then "Base" else "After".
 
The #date function It works like: #date(year, month,day).
 
When you need a dynamic date you can replace the #date function and its content with a dynamic function like Date.AddDays , Date.AddMonths, Date.AddYears when you substract a number of days/months/years from a given date.
 
For example:
 
if [Date] < 
Date.From(Date.AddMonths(DateTime.LocalNow(),-6))
then "Base" else "After".
 
You will need to wrap the Data.AddMonths function in a Date.From because Date.AddMonths returns a datetime instead of a date and comparing a date  with a datetime will result in an error.
 
 

View solution in original post

2 REPLIES 2
ChielFaber
Solution Supplier
Solution Supplier

When you use a specific date you can use a hardcoded date. For this you can create a custom column with the folloewing if statement and the #date function:

if [Date] < #date(2023, 3, 1) then "Base" else "After".
 
The #date function It works like: #date(year, month,day).
 
When you need a dynamic date you can replace the #date function and its content with a dynamic function like Date.AddDays , Date.AddMonths, Date.AddYears when you substract a number of days/months/years from a given date.
 
For example:
 
if [Date] < 
Date.From(Date.AddMonths(DateTime.LocalNow(),-6))
then "Base" else "After".
 
You will need to wrap the Data.AddMonths function in a Date.From because Date.AddMonths returns a datetime instead of a date and comparing a date  with a datetime will result in an error.
 
 

Thanks @ChielFaber solution works 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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