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
necmik
Employee
Employee

Adding meta data to a function type column

Hi,

 

I am trying to add metadata when calling AddColumn function.

 

The new column is a function type and its body will be empty (just a reference). It works fine with this command:

FunctionColumnAddedTable = Table.AddColumn(Source, "FunctionColumn", each (InputColumn1 as text) as any => ...)

 

I want to add meta to this function such as:

FunctionColumnAddedTable = Table.AddColumn(Source, "FunctionColumn", each (InputColumn1 as text) as any => ... meta [Description = "Desc"])

 

But when I try to get the metada, I see it is empty:  

MetadataColumn = Table.AddColumn(FunctionColumnAddedTable , "MetadataColumn", each Value.Metadata([FunctionColumn]))

 

Any idea about my mistake?

1 ACCEPTED SOLUTION

Hi @ImkeF ,

 

"That's metadata in the result of a function." helped me to try enclosing the function definition between paranthesis to add metadata to the function body. And it worked by doing:

FunctionColumnAddedTable = Table.AddColumn(Source, "FunctionColumn", each ((InputColumn1 as text) as any => ...) meta [Description = "Desc"])

 

Thank you very much for your help

View solution in original post

4 REPLIES 4
ImkeF
Super User
Super User

Hi @necmik ,
this is what that query returns for me:

ImkeF_0-1673533961571.png

But now I see what you are after. That's metadata in the result of a function.
It would work like so:

() => 
Table.FromRecords(
    {
        [noMetadataHere = 1, 
        WithMetadataOfTheInvokedFunction = 2 meta [InvokedMetadata = "Some metadata here"]
        ]
    }
)


Please also check the file enclosed.


Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hi @ImkeF ,

 

"That's metadata in the result of a function." helped me to try enclosing the function definition between paranthesis to add metadata to the function body. And it worked by doing:

FunctionColumnAddedTable = Table.AddColumn(Source, "FunctionColumn", each ((InputColumn1 as text) as any => ...) meta [Description = "Desc"])

 

Thank you very much for your help

ImkeF
Super User
Super User

Hi @necmik ,
not sure I fully get it, but you might have created a nested function. Try omitting the each syntax sugar like so:

FunctionColumnAddedTable = Table.AddColumn(Source, "FunctionColumn", (InputColumn1 as text) as any => ... meta [Description = "Desc"])

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hi @ImkeF ,

 

Thank you for your answer. I have already tried it but it didn't work. What I am trying to do is creating a function similar to AIFunctions.Contents(). Its data column basically includes a function reference and metadata related to the this reference. You can check it by runing M query below. You can see that some functions have metadata (such as Cognitive Services ones):


let
    MetadataColumn = Table.AddColumn(AIFunctions.Contents(), "MetadataColumn", each Value.Metadata([Data]))
in
    MetadataColumn

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors
Top Kudoed Authors