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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.