Currency.From

#

In this article, we will take a closer look at the M code behind the Power Query M function Currency.From. We will examine how this function works, what parameters it accepts, and how it can be used to convert currency values from one currency to another.

What is the Currency.From Function?

The Currency.From function is a built-in M function in Power Query that allows users to convert currency values from one currency to another. It takes two parameters: the amount to be converted, and the currency code of the original currency.

Here is the basic syntax of the Currency.From function:

Currency.From(amount as any, fromCurrency as text) as nullable number

``` The first parameter, amount, can be any value that can be converted to a number, such as a numeric value, a date/time value, or a string value. The second parameter, fromCurrency, is a text value that represents the currency code of the original currency. For example, if you want to convert \$100 USD to Euros, you would use the following formula: ```

Currency.From(100, “USD”)

``` This would return the equivalent value in Euros based on the current exchange rate. How Does the Currency.From Function Work? The Currency.From function works by using the currency exchange rates provided by a data source. By default, it uses the exchange rates provided by the European Central Bank (ECB), which are updated daily. However, users can also specify their own exchange rate data source if they have access to one. The Currency.From function takes the amount to be converted and the currency code of the original currency as input. It then looks up the exchange rate for the original currency against the target currency and uses that exchange rate to calculate the equivalent value in the target currency. For example, if you want to convert \$100 USD to Euros, the Currency.From function would look up the current exchange rate for USD/EUR, and use that rate to calculate the equivalent value in Euros. Using the Currency.From Function in Power Query The Currency.From function can be used in Power Query to transform and model data that contains currency values. For example, if you have a data set that contains sales data in different currencies, you can use the Currency.From function to convert all the values to a common currency for analysis. Here is an example of how to use the Currency.From function in Power Query: 1. Open Power Query and connect to your data source. 2. Select the column that contains the currency values you want to convert. 3. Click on the Transform tab and select the Currency.From function from the drop-down list of functions. 4. Enter the currency code of the original currency in the fromCurrency parameter. 5. Click on the gear icon next to the function to expand the options. 6. Select the column that contains the amount to be converted and click OK. 7. Click Close & Apply to apply the transformation and load the data into Power BI. The Currency.From function is a powerful tool in Power Query that allows users to convert currency values from one currency to another. It is easy to use and can be integrated into data transformation and data preparation workflows. By understanding the M code behind this function, users can gain a deeper understanding of how it works and how to use it effectively in their data analytics and data science projects. Power Query and M Training Courses by G Com Solutions (0800 998 9248) Power Query and M Intensive Training Course £1,050.00 – £26,550.00 Select optionsContinue Loading Done Power Query and M Introduction £395.00 – £9,750.00 Select optionsContinue Loading Done Power Query and M Intermediate £395.00 – £9,750.00 Select optionsContinue Loading Done Power Query and M Advanced £395.00 – £9,750.00 Select optionsContinue Loading Done Upcoming Courses Contact Us Subject Your Name (required) Company/Organisation Email (required) Telephone Training Course(s) Power BI Intensive TrainingPower BI introduction Power BI IntermediatePower BI AdvancedDAXPower Query MPower BI CertificationPower BI AdministrationPower PlatformPower AutomatePower AppsOTHER Your Message Upload Example Document(s) (Zip multiple files) ```
``` ```
``` ```
``` ```
``` ```
``` ```