Power Query Value.RemoveMetadata: How to Use It
In this article
Value.RemoveMetadata strips all metadata from a value in Power Query, returning just the underlying data. It is useful when metadata (such as column names, data types, or custom tags) is causing errors, bloating your query, or interfering with comparisons. You need Power Query Editor in Excel or Power BI Desktop; no extra installation is required.
What You'll Need
- Excel (Microsoft 365 or 2019+) or Power BI Desktop with Power Query Editor.
- A query or data source loaded into Power Query.
- Basic familiarity with the Power Query formula language (M).
Step-by-Step
- Open Power Query Editor. In Excel, go to Data > Get Data > Launch Power Query Editor. In Power BI Desktop, click Transform Data on the Home ribbon. Labels may vary slightly by version or region.
- Load or create a query. Connect to your data source (e.g., Excel workbook, CSV, database) and select the table or range you want to work with. The query appears in the Queries pane on the left.
- Identify the step where metadata is a problem. Metadata often appears as column headers, data type icons, or custom properties. If you see errors like "We cannot convert a value of type Table to type Text" or unexpected behavior when comparing values, metadata may be the culprit.
- Add a custom column or modify an existing step. To apply Value.RemoveMetadata to a specific value, you can use the formula bar. For example, to remove metadata from a column named "Data", add a custom column with the formula:
= Value.RemoveMetadata([Data]). Alternatively, edit an existing step in the formula bar by wrapping the value expression with Value.RemoveMetadata. - Use Advanced Editor for more control. Right-click your query and select Advanced Editor. Locate the step where you want to apply the function. For instance, if you have a step that returns a table, you can wrap the table value:
CleanedTable = Value.RemoveMetadata(PreviousStep). Be aware that removing metadata from a table may also remove column names and types, so use with caution. - Apply the function to a list or record. If you have a list with metadata, use
Value.RemoveMetadata(myList). For records,Value.RemoveMetadata(myRecord)removes all metadata fields, leaving only the record's fields. - Check the result. After applying the function, preview the data to ensure metadata is gone and the underlying values are intact. If you removed metadata from a table, you may need to reapply column headers and data types manually.
- Close and load. Once satisfied, click Close & Load (Excel) or Close & Apply (Power BI) to apply the changes.
Common Mistakes
- Removing metadata from a table without redefining headers. Value.RemoveMetadata on a table removes column names and types, leaving generic Column1, Column2, etc. You must promote headers and set data types again.
- Using the function on a scalar value. Scalars like numbers or text have no metadata, so the function returns the value unchanged. It is harmless but unnecessary.
- Forgetting that metadata can be nested. Removing metadata from a record does not remove metadata from its fields. Apply the function to each field if needed.
- Assuming it removes all metadata types. Value.RemoveMetadata removes metadata associated with the value itself, but not metadata that is part of the value's structure (e.g., column metadata in a table is removed, but the table structure remains).
Tips
- Use Value.RemoveMetadata when you need to compare values without metadata interference, such as in equality checks.
- Combine with Value.Metadata to inspect metadata before removal.
- For tables, consider using Table.TransformColumnTypes and Table.PromoteHeaders after removing metadata to restore structure.
- Test on a copy of your query to avoid breaking existing steps.
Troubleshooting
- Error: "We cannot convert a value of type Table to type Text" – This often occurs when metadata is present and a function expects text. Apply Value.RemoveMetadata to the value before passing it to the function.
- Column names disappeared after using Value.RemoveMetadata – This is expected for tables. Reapply headers using Table.PromoteHeaders or rename columns manually.
- Function has no effect – The value may not have metadata, or the metadata is nested. Check with Value.Metadata to confirm.
- Query breaks after applying function – Undo the step or remove it. Ensure you are applying the function to the correct value and not to a step reference incorrectly.
Frequently Asked Questions
What does Value.RemoveMetadata do?
It returns the input value with all metadata removed. For example, a number with a custom tag becomes a plain number.
When should I use Value.RemoveMetadata?
Use it when metadata causes errors, interferes with comparisons, or when you need a clean value for further processing.
Does it work on tables?
Yes, but it removes column names and data types, so you'll need to reapply them.
Can I remove metadata from a specific column only?
Yes, apply the function to that column's value within a transformation step, e.g., = Value.RemoveMetadata([ColumnName]).
Is Value.RemoveMetadata available in all Power Query versions?
It is available in Excel 2016+ and Power BI Desktop. Check your version's documentation if unsure.
What is the difference between Value.RemoveMetadata and Value.Metadata?
Value.Metadata returns the metadata record, while Value.RemoveMetadata returns the value without metadata.