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
MR2001
Helper II
Helper II

Error trying to add a custom column

I am getting the following error when trying to add a custom column: "The name FORMAT wasn't recognized"

 

custom_column.jpgPlease advise.

 

Thank you.

 

 

 

1 ACCEPTED SOLUTION
kcantor
Community Champion
Community Champion

@MR2001

Instead of working in the query editor, have you tried adding a calculated column within the data model? I just used Format in that sense in the Data Model by adding the calculated column there as opposed to writing an "M" string in Query Editor. I used a simple Year-Week = [Year]&"-"&FORMAT([WeekNumber],"00") just to make sure FORMAT worked as desired in the datamodel.

Hope this helps.

As an added hint:

 I am new to M but I can tell you that all caps throws an error. Only capitilize the F in Format but I don't think Format works anyway.

Not really helpful for this but the all caps thing might come in handy at some point in the future.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

10 REPLIES 10
arify
Employee
Employee

Hi @MR2001, if you can't find what you need in there, can you describe what you want to do so we may be able to help?

Thanks Arify, problem is resolved now, I was just trying to format a DateTime field to include only Date information.

kcantor
Community Champion
Community Champion

@MR2001

Instead of working in the query editor, have you tried adding a calculated column within the data model? I just used Format in that sense in the Data Model by adding the calculated column there as opposed to writing an "M" string in Query Editor. I used a simple Year-Week = [Year]&"-"&FORMAT([WeekNumber],"00") just to make sure FORMAT worked as desired in the datamodel.

Hope this helps.

As an added hint:

 I am new to M but I can tell you that all caps throws an error. Only capitilize the F in Format but I don't think Format works anyway.

Not really helpful for this but the all caps thing might come in handy at some point in the future.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks, Kcantor, I added a custom column using FORMAT function and it worked. I also tried something similar using "M" language:

 

Custom Date = Number.ToText(Date.Month([#"history#action_timestamp"])) & "/" & Number.ToText(Date.Year([#"history#action_timestamp"]))

 

Thanks,

M.R.

Greg_Deckler
Super User
Super User

Looks like you are trying to use a DAX function in Power Query "M" code.

 

https://msdn.microsoft.com/en-us/library/mt211003.aspx

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you Smoupre, I realize now that "M" and DAX are different.

kcantor
Community Champion
Community Champion

Fortunately, for those of us new to both DAX and M we usually get the option of which to use. I find DAX easier but am working to learn M. Its a process.

Glad it works for you.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Sean
Community Champion
Community Champion

@kcantor same here I agree

 

But they can help us learn faster if they add intellisense in the Query Editor

 

so you get a little help when writing formulas there - best way to learn

kcantor
Community Champion
Community Champion

True that @Sean. they will probably add it as soon as I reach a rudimentary level.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Sean
Community Champion
Community Champion

Smiley Very HappySmiley Very HappySmiley Very Happy

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.