# Int64.From

## Understanding the Int64.From Function

Before we dive into the M code behind the Int64.From function, let’s take a quick overview of what this function does. The Int64.From function converts a text string to a 64-bit integer value. This can be useful when working with large numbers that cannot be represented by the standard 32-bit integer data type.

Here’s an example of using the Int64.From function:

let

textValue = “9223372036854775807”,

intValue = Int64.From(textValue)

in

intValue

In this example, we have a text string representing the maximum value of a 64-bit integer. We use the Int64.From function to convert this text string to a 64-bit integer value.

## The M Code Behind the Int64.From Function

The M code behind the Int64.From function is relatively simple. Here's the code:

(Int64.From as (textValue) =>

Number.From(Text.Replace(textValue, “,”, “”)))

Let's break down this code into its individual components.

### The Int64.From Function Definition

The first part of the code defines the Int64.From function and its argument:

(Int64.From as (textValue) => …)

This code defines a function named Int64.From that takes a single argument named textValue. The arrow (=>) indicates that the function definition is not yet complete.

### The Text.Replace Function

The next part of the code uses the Text.Replace function to remove any commas from the textValue argument:

Number.From(Text.Replace(textValue, “,”, “”))

The Text.Replace function takes two arguments: the textValue argument and a string to replace (in this case, a comma) with a blank space. The resulting text string is then passed to the Number.From function, which converts the text string to a number data type.

### The Final Function

Putting it all together, the final function code looks like this:

(Int64.From as (textValue) =>

Number.From(Text.Replace(textValue, “,”, “”)))

This code defines the Int64.From function so that it takes a single argument (textValue), removes any commas from it using the Text.Replace function, and then converts the resulting text string to a number data type using the Number.From function.

In conclusion, the Int64.From function in Power Query is a useful tool for converting text strings to 64-bit integer values. The M code behind this function is relatively simple, using the Text.Replace and Number.From functions to perform the conversion. With this understanding, you can better utilize the Int64.From function in your Power Query projects.

Subject