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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
mazwro
Helper I
Helper I

Date formula - need to replicate sql

I have a two tables - one takes source direcly from SQL, and I am adding another formated in Power bi and I need to apply the same filters. And here is where my issues start

 

The SQL has it like this:

 

 

WHERE MONTH(date_order) = MONTH(CURRENT_DATE())#(lf)AND YEAR(date_order) = YEAR(CURRENT_DATE())

 

 

 

The table I have in sql comes from a different place so I need to apply this in power BI.

I created a custom column and I want to filter values 1 later:

 

 

if Date.Month([date_of_order]) = Date.Month(Date.From(DateTime.LocalNow())) 
&
Date.Year([date_of_order]) = Date.Year(Date.From(DateTime.LocalNow()))
then  "1" else"0"

 

 

But this gives me an error which I do not understand:

mazwro_0-1720786854552.png

Any ideas how to fix it?

 

1 ACCEPTED SOLUTION
miTutorials
Super User
Super User

Try the below code.

 

if Date.Month([date_of_order]) = Date.Month(Date.From(DateTime.LocalNow())) 
and 
Date.Year([date_of_order]) = Date.Year(Date.From(DateTime.LocalNow()))
then  "1" else"0"

View solution in original post

2 REPLIES 2
miTutorials
Super User
Super User

Try the below code.

 

if Date.Month([date_of_order]) = Date.Month(Date.From(DateTime.LocalNow())) 
and 
Date.Year([date_of_order]) = Date.Year(Date.From(DateTime.LocalNow()))
then  "1" else"0"

This worked, so seems power query does not like & signs. Thanks

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

October NL Carousel

Fabric Community Update - October 2024

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