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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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

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
Community Champion
Community Champion

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

necmik
Microsoft Employee
Microsoft Employee

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
Community Champion
Community Champion

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

necmik
Microsoft Employee
Microsoft Employee

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.