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
Stroop
Frequent Visitor

Simplest thing in the world

New to Bi. Just playing about. Thought I was doing the simplest thing in the world but apparently it's not.

 

I have just 1 table for simplicity. In my data there is a timestamp field. I wanted to create month and year columns based on this timestamp. How hard could it be?

 

I go to create a customer variable.

 

In the new column name box I put "year" because that seems a sensible name.

 

In the customn column formula I put = year([time])

 

BI then tells me there is no syntax errors have been detected. great stuff. should be no issues then. Oh wait. I click ok and it tells me that "Expression.Error: The name 'year' wasn't recognized.  Make sure it's spelled correctly."

 

Apparently just finding information related to doing this type of query is impossible too so if anyone can just tell me how I can do this that'd be great. 

 

 

1 ACCEPTED SOLUTION
dilumd
Solution Supplier
Solution Supplier

Hi,

 

You can do this in the Query editor itself, just take a duplicate of the datetime column you have, then right click and go to below.

 

dd.png

View solution in original post

2 REPLIES 2
v-sihou-msft
Employee
Employee

 

@Stroop

 

The custom column you add in Query Editor is based on Power Query syntax instead of DAX. So you should use "Date.Year()" function.

 

5.PNG

 

Regards,

dilumd
Solution Supplier
Solution Supplier

Hi,

 

You can do this in the Query editor itself, just take a duplicate of the datetime column you have, then right click and go to below.

 

dd.png

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.