Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Value.VersionIdentity Function Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The Value.VersionIdentity function in Power Query returns a unique identifier for the version of a value. It is primarily used to detect whether a value (like a table, record, or custom object) has changed between refreshes, which is useful for caching, incremental loading, or conditional logic. You do not need any special setup—just a Power Query environment (Excel, Power BI, or Power Query Online). The function takes one argument: the value you want to check.

What You'll Need

  • A Power Query environment (Excel's Power Query Editor, Power BI Desktop, or Power Query Online).
  • A value to test—this can be a table, record, list, or any M expression.
  • Basic familiarity with the Power Query M language (writing custom columns or steps).

Step-by-Step

  1. Open Power Query Editor – In Excel, go to the Data tab and click Get Data > Launch Power Query Editor. In Power BI Desktop, go to Home > Transform Data.
  2. Create a simple query to test the function – In the Query Editor, click New Source > Blank Query (or right-click in the Queries pane and choose New Query > Blank Query). This gives you a blank query where you can type M code directly.
  3. Enter a basic expression using the function – In the formula bar (or the Advanced Editor), type:
    = Value.VersionIdentity(1)
    This returns a version identifier for the number 1. Press Enter.
  4. Observe the output – The result will be a binary or text value that uniquely identifies the version of the value. It is not human-readable, but it is consistent for the same value across refreshes within the same session.
  5. Test with a table – Create a table by entering:
    = Value.VersionIdentity(Table.FromRecords({[A=1]}))
    This returns a version ID for that table structure.
  6. Use it in a custom column (practical example) – In any query, add a custom column by going to Add Column > Custom Column. Enter a formula like:
    Value.VersionIdentity([YourColumn])
    This will generate a version ID for each value in that column.
  7. Compare version identities – To check if a value changed, store the previous ID in a variable (e.g., in a let expression) and compare it to the current one. For example:
    let
      oldVersion = Value.VersionIdentity(1),
      newVersion = Value.VersionIdentity(2),
      areSame = (oldVersion = newVersion)
     in
      areSame
    This returns false because the values differ.
  8. Apply in a real scenario – For incremental refresh, you might compare the version identity of a table before and after a refresh to decide whether to overwrite a cached table. Use an if statement in M to branch based on the comparison.

Common Mistakes

  • Assuming the output is readable – The function returns a binary value, not a text label. Do not try to interpret it; use it only for equality comparisons.
  • Using it on volatile values – If the value contains functions, random numbers, or external data that changes every time, the version identity will change each call, making comparisons useless.
  • Forgetting that the function is case-sensitive – In M, Value.VersionIdentity must be spelled exactly as shown. A typo will cause an error.
  • Expecting it to work across sessions – The version identity is not guaranteed to be stable across different Power Query sessions or after the file is reopened. It is meant for within-session comparisons.

Tips

  • Use Value.VersionIdentity for detecting changes in configuration tables or parameters that are loaded from external sources.
  • Combine it with try and otherwise to handle cases where the function might fail (e.g., on certain custom objects).
  • For performance, avoid calling the function on large tables repeatedly; store the result in a variable if you need to compare multiple times.
  • If you need a stable hash for a value, consider using Text.MD5 (available in later versions) instead, but note it works on text, not arbitrary values.
  • Remember that the function is part of the standard M library, so it works in any Power Query environment.

Troubleshooting

  • Error: “Value.VersionIdentity is not a valid function” – This usually means you are using an older version of Power Query that does not support this function. Update your Excel or Power BI Desktop to the latest version.
  • Function returns null – This can happen if the value is null itself. Test with a non-null value first.
  • Version identity changes unexpectedly – If you are comparing two identical-looking values but they are stored in different data types (e.g., text vs. number), the identities will differ. Ensure the data types match.
  • Cannot use in a custom column – If you get an error when adding a custom column, verify that the column reference is correct and that the value is not a table (tables in rows are not allowed). Use Value.VersionIdentity([Column]) only on scalar values.
  • Function works in query but not in a function – If you are defining a custom function that calls Value.VersionIdentity, make sure the parameter type is set to any to avoid type mismatches.

Frequently Asked Questions

What exactly does Value.VersionIdentity return?

It returns a binary value that uniquely identifies the version of the given value at that moment. It is not meant to be read or compared to a pre-known string; only equality comparisons are meaningful.

Can I use this to detect if a table has changed after a refresh?

Yes, but only within the same query execution. If you refresh a query, the version identity of the table may change if the underlying data changed. You can compare the identity before and after a refresh step to see if the data is different.

Is Value.VersionIdentity the same as a hash?

No. It is a version identifier, not a cryptographic hash. It is not guaranteed to be unique across different values, and it is not stable across sessions. For hashing, use Text.MD5 or Text.SHA1 on a serialized version of the value.

Does this function work on all data types?

It works on most M values, including numbers, text, dates, records, lists, and tables. However, it may not work on some custom objects or functions. If you get an error, wrap it in a try expression.

Can I use it to compare two different queries?

Yes, you can call Value.VersionIdentity on the outputs of two queries and compare the results, as long as both queries are evaluated in the same session. If you need to compare across sessions, store the value as a text or binary and compare externally.

Why does the function return a binary value instead of text?

Binary is more compact and efficient for internal comparisons. You can convert it to text using Binary.ToText if you need to display it, but that is rarely necessary.