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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
kt3734
Frequent Visitor

Year

Hi,

I am trying to filter the date >=2021 , but the syntax below didn't work.  Can you please help with this since I am new to DAX.

 

FILTER ('Backlog','Backlog'(Year([Order Date])) >= 2021

 

Thanks

3 REPLIES 3
djurecicK2
Super User
Super User

Hi @kt3734 ,

 Are you able to set your Order Date type to Date instead of text? That's what I would do.

 

Here is more information about the Year function.

https://learn.microsoft.com/en-us/dax/year-function-dax

  • When the date argument is a text representation of the date, the function uses the locale and date time settings of the client computer to understand the text value in order to perform the conversion. Errors may arise if the format of strings is incompatible with the current locale settings. For example, if your locale defines dates to be formatted as month/day/year, and the date is provided as day/month/year, then 25/1/2009 will not be interpreted as January 25th of 2009 but as an invalid date.

djurecicK2
Super User
Super User

Hi @kt3734 ,

 Try this

FILTER ('Backlog',YEAR('Backlog'([Order Date])) >= 2021...

 

 

Thank your for your reponse.  I got the error below, the reason is the column order date is text (2/3/2021 9:00:00 AM)

DAX comparison operations do not support comparing values of type Integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

 

my order date from the table is this format: 2/3/2021 9:00:00 AM, I  want to get 

year(order date) = 2021 

and date format: 2/3/2021 

I try both below but didn't work.  Can you show me how to get the correct syntax below?

FILTER ('Backlog',YEAR('Backlog'([Order Date])) >="2021"
FILTER ('Backlog',DATEVALUE('Backlog'([Order Date])) >="1/1/221"

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors