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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
ilcaa72
Helper IV
Helper IV

Best way to add YEAR from date column

i have a Sales table that has dates in a column, 4/15/2015, etc.  I just wanted to show the Years. I thought I could just make a new measure and use a formula similiar to this...

 

years = YEAR('Sales Table' [dates])

i dont even get the table/column names with Intellisense... why cant I do something like this in PBI?  Whats the proper way?  a short explanation would be appreciated.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @ilcaa72,

 

YEAR function expect a single date in datetime or text format, containing the year you want to find. 
You can get:

YEAR(LASTDATE('Sales Table' [dates]))

or

YEAR(FIRSTDATE(Calendar[Date]))

To obtain the list of years you can mark the field as Date Hierarchy and select only the years

 

años.png

 

Regards.

View solution in original post

TomMartens
Super User
Super User

Hey,

 

if you create a calculated column in your sales table you can use the function you already have. The benefit of creating a calculated column over a measure is that you can use the calculated column as a slicer. The price you pay, is an additional memory footprint, depending on the number of rows in your sales table.

 

I would recomment that you consider to create a separate date table and relate this table with your sales table. Here you will find some date related calculations that heavily rely on the usage of a separate date table: https://www.daxpatterns.com/time-patterns/

By the way, intellisense recognizes that the context expects an aggregate function, for this reason it does suggest a tablename. This behavior often reminds me that I should check my syntax and the context 🙂

 

Hope this what you are looking for

 

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey,

 

if you create a calculated column in your sales table you can use the function you already have. The benefit of creating a calculated column over a measure is that you can use the calculated column as a slicer. The price you pay, is an additional memory footprint, depending on the number of rows in your sales table.

 

I would recomment that you consider to create a separate date table and relate this table with your sales table. Here you will find some date related calculations that heavily rely on the usage of a separate date table: https://www.daxpatterns.com/time-patterns/

By the way, intellisense recognizes that the context expects an aggregate function, for this reason it does suggest a tablename. This behavior often reminds me that I should check my syntax and the context 🙂

 

Hope this what you are looking for

 

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Hi @ilcaa72,

 

YEAR function expect a single date in datetime or text format, containing the year you want to find. 
You can get:

YEAR(LASTDATE('Sales Table' [dates]))

or

YEAR(FIRSTDATE(Calendar[Date]))

To obtain the list of years you can mark the field as Date Hierarchy and select only the years

 

años.png

 

Regards.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors