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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mazwro
Helper II
Helper II

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.