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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.