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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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