Value.RemoveMetadata

Updated on

Value.RemoveMetadata is a Power Query M function that strips the input value of metadata. The function returns the input value without metadata.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Value.RemoveMetadata(
   value as any,
   optional metaValue as any,
) as any

Description

Value.RemoveMetadata removes the attached metadata from a given value. The function returns the original value without its associated custom metadata. A side effect of applying this function is that it leaves QueryFolding Metadata.

Examples

Here’s some examples of how you can use the Value.RemoveMetadata function.

Example 1: Removing Metadata from a Value

Imagine we have a value with metadata attached. For instance:

2024 meta [ Year = "Year of the Dragon", Quality = "Courage" ]

This metadata provides additional information about the value. To remove the metadata, you can use Value.RemoveMetadata like this:

Value.RemoveMetadata( MetaValue )

Once the metadata is removed, you can use the Value.Metadata function to check whether any metadata remains. Here’s the complete query to demonstrate these steps:

// Returns [ QueryFolding = Error ]
let
  MetaValue = 2024 meta [ Year = "Year of the Dragon", Quality = "Courage" ],
  NoMetaValue = Value.RemoveMetadata( MetaValue ),
  InspectMeta = Value.Metadata( NoMetaValue )
in
  InspectMeta 

When you inspect the metadata after applying Value.RemoveMetadata, you’ll find that it no longer contains the original metadata. However, it will still return a record related to QueryFolding, including an error.

This happens because the operation cannot be folded when it’s not working directly with a database. It’s important to note that you cannot remove this specific QueryFolding metadata. Once metadata is added, this system-level information will always be visible.

You’ll find that the only metadata it will return is information about QueryFolding and an error. The operation itself can’t fold because it’s not working with a database. However, you won’t be able to delete that Metadata record. After adding some metadata it is always visible.

Example 2: Replacing Metadata with an Empty Record

Another way to remove metadata from a value is by using the Value.ReplaceMetadata function. Instead of explicitly removing the metadata, this method replaces it with an empty record ([ ]). Here’s how you can do this:

// Returns [ QueryFolding = Error ]
let
  MetaValue = 2024 meta [ Year = "Year of the Dragon", Quality = "Courage" ],
  NoMetaValue = Value.ReplaceMetadata( MetaValue, [ ] ),
  InspectMeta = Value.Metadata( NoMetaValue )
in
  InspectMeta 

Learn more about Value.RemoveMetadata in the following articles:

  • Power Query M Primer (Part 20): Metadata
    The article explains how Power Query allows attaching metadata—additional information—to values. It specifies methods to inspect, set, and merge metadata, and discusses its applications, such as parameter configuration in Power BI. » Read more

Other functions related to Value.RemoveMetadata are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/value-removemetadata

2023-2026 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy