# LOG

## Understanding the LOG Function in Power BI

The LOG function in Power BI is used to calculate the logarithm of a given number with a specified base. The syntax for the LOG function is as follows:

LOG(❰number❱, ❰base❱)

``` Here, the `❰number❱` parameter is the value for which you want to calculate the logarithm, and the `❰base❱` parameter is the base of the logarithm. For example, if you want to calculate the logarithm of 10 with base 2, you would use the following formula: ```

LOG(10, 2)

``` This would return the result 3.3219, which is the logarithm of 10 with base 2. Using the LOG Function in Power BI To use the LOG function in Power BI, you need to follow these steps: 1. Open the Power BI Desktop and create a new report. 2. Click on the "New Measure" button in the "Modeling" tab. 3. Enter a name for the measure, such as "Logarithm." 4. In the formula bar, enter the syntax for the LOG function, with the appropriate parameters. For example, to calculate the logarithm of a column named "Sales" with base 10, you would use the following formula: ```

Logarithm = LOG(Sales, 10)

``` 5. Press Enter to create the measure. 6. You can now use the measure in your visualizations, such as charts or tables. Practical Examples of Using the LOG Function in Power BI Let's take a look at some practical examples of using the LOG function in Power BI. Example 1: Calculating the Logarithmic Returns of a Stock Suppose you have a dataset containing the daily stock prices of a company. You can use the LOG function to calculate the logarithmic returns of the stock. The formula for calculating the logarithmic returns is as follows: ```

Logarithmic Return = LOG(Current Price / Previous Price)

``` Here, the "Current Price" is the price of the stock on the current day, and the "Previous Price" is the price of the stock on the previous day. To implement this formula in Power BI, you can create the following measure: ```

Logarithmic Return = LOG(DIVIDE(Sales, CALCULATE(SALES, PREVIOUSDAY(DATE))))

``` Example 2: Calculating the Compound Annual Growth Rate (CAGR) The LOG function can also be used to calculate the Compound Annual Growth Rate (CAGR) of an investment. The formula for calculating CAGR is as follows: ```

CAGR = (Ending Value / Beginning Value)^(1 / Number of Years) – 1

``` Here, the "Ending Value" is the value of the investment at the end of the period, the "Beginning Value" is the value of the investment at the beginning of the period, and the "Number of Years" is the length of the period in years. To implement this formula in Power BI, you can create the following measure: ```

CAGR = POWER(DIVIDE(LAST(Sales), FIRST(Sales)), 1 / COUNTROWS(Sales)) – 1

``` The LOG function is an important mathematical function in Power BI that can be used in a variety of scenarios. By understanding its syntax and functionality, you can use it to perform complex calculations and gain valuable insights from your data. We hope this article has helped you understand how to use the LOG function in Power BI and provided you with some practical examples to get started. Power BI DAX Training Courses by G Com Solutions (0800 998 9248) Power BI DAX Intensive Training Course £1,260.00 – £31,860.00 Select optionsContinue Loading Done Power BI DAX Introduction £474.00 – £11,700.00 Select optionsContinue Loading Done Power BI DAX Intermediate £474.00 – £11,700.00 Select optionsContinue Loading Done Power BI DAX Advanced £474.00 – £11,700.00 Select optionsContinue Loading Done Upcoming Courses 16-18 September 202411-13 November 2024 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) ```
``` ```
``` ```
``` ```
``` ```
``` ```