Value.VersionIdentity

D

T

The M Code Behind the Power Query M function Value.VersionIdentity

What is the M language?

M is the programming language used by Power Query to perform data transformations. It is a functional language that is similar to other programming languages like F# and Haskell. M is used to define queries, functions, and expressions that are used to transform data.

The Value.VersionIdentity function

The Value.VersionIdentity function returns a record that contains information about the current version of the Power Query engine that is running. The record contains the following fields:

– BuildDate: The date that the engine was built.

– BuildNumber: The build number of the engine.

– FullVersion: The full version number of the engine.

– MajorVersion: The major version number of the engine.

– MinorVersion: The minor version number of the engine.

– Revision: The revision number of the engine.

– Version: The version number of the engine.

Here is an example of how to use the Value.VersionIdentity function in Power Query:


let

version = Value.VersionIdentity(),

buildDate = version[BuildDate],

buildNumber = version[BuildNumber],

fullVersion = version[FullVersion],

majorVersion = version[MajorVersion],

minorVersion = version[MinorVersion],

revision = version[Revision],

versionNumber = version[Version]

in

versionNumber


This code defines a variable called “version” that contains the record returned by the Value.VersionIdentity function. It then extracts the individual fields from the record and assigns them to separate variables.

How to use the Value.VersionIdentity function

The Value.VersionIdentity function can be useful in a number of scenarios, such as:

– Verifying that the correct version of the Power Query engine is installed.

– Debugging Power Query scripts by checking the version of the engine that is running.

– Checking for updates to the Power Query engine.

Here are some examples of how to use the Value.VersionIdentity function in these scenarios:

Verifying the version of the Power Query engine

To verify that the correct version of the Power Query engine is installed, you can use the Value.VersionIdentity function to check the version number. For example:


let

version = Value.VersionIdentity(),

versionNumber = version[Version]

in

if versionNumber = "2.96.5102.261" then

"Correct version installed"

else

"Incorrect version installed"


This code checks the version number returned by the Value.VersionIdentity function and compares it to the expected version number. If the version numbers match, it returns a message indicating that the correct version is installed. Otherwise, it returns a message indicating that the incorrect version is installed.

Debugging Power Query scripts

If you’re experiencing issues with a Power Query script, you can use the Value.VersionIdentity function to check the version of the engine that is running. This can be helpful in identifying issues that are specific to certain versions of the engine. For example:


let

version = Value.VersionIdentity(),

versionNumber = version[Version],

result = // Power Query script goes here

in

result


This code defines a variable called “version” that contains the record returned by the Value.VersionIdentity function. It then defines a variable called “result” that contains the Power Query script you want to debug. By including the version information in the script, you can identify whether the issue is specific to a certain version of the engine.

Checking for updates to the Power Query engine

Finally, you can use the Value.VersionIdentity function to check for updates to the Power Query engine. By comparing the version number returned by the function to the latest version number, you can determine whether a new version is available. For example:


let

version = Value.VersionIdentity(),

versionNumber = version[Version],

latestVersionNumber = "2.97.750.0"

in

if versionNumber = latestVersionNumber then

"Up to date"

else

"New version available"


This code checks the version number returned by the Value.VersionIdentity function and compares it to the latest version number. If the version numbers match, it returns a message indicating that the version is up to date. Otherwise, it returns a message indicating that a new version is available.

The Value.VersionIdentity function is a useful tool for working with Power Query in Excel. By returning information about the current version of the Power Query engine, it can be used to verify that the correct version is installed, debug Power Query scripts, and check for updates. By understanding the M code behind this function, you can take advantage of its full capabilities and improve your Power Query workflows.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)