GCD

GCD

How to Use the Power BI DAX function GCD

Syntax of the GCD Function

The syntax of the GCD function is as follows:


GCD(number1, [number2], …)


The GCD function takes one or more numbers as arguments and returns the greatest common divisor of those numbers. The arguments can be numbers, cell references, or expressions that evaluate to numbers. The GCD function ignores any non-numeric values in the arguments.

Using the GCD Function in Power BI

To use the GCD function in Power BI, follow these steps:

1. Create a new measure in the Power BI desktop.

2. In the formula bar, enter the GCD function syntax with the desired arguments. For example, to find the GCD of two numbers, enter:


GCD([Number1],[Number2])


3. Replace [Number1] and [Number2] with the appropriate column or measure names that contain the numbers you want to find the GCD of.

4. Name the measure something descriptive, such as "GCD of Numbers".

5. Press Enter to create the measure.

Examples of Using the GCD Function

Let's look at some examples of how to use the GCD function in Power BI.

Example 1: Finding the GCD of Two Numbers

Suppose you have a table that contains two columns, Number1 and Number2, and you want to find the GCD of these numbers. Here's how you can do it:

1. Create a new measure in the Power BI desktop.

2. In the formula bar, enter the GCD function syntax with the appropriate arguments. For example, if Number1 is in the column "Column1" and Number2 is in the column "Column2", enter:


GCD([Column1],[Column2])


3. Name the measure something descriptive, such as "GCD of Numbers".

4. Press Enter to create the measure.

The measure will now calculate the GCD of the numbers in the specified columns.

Example 2: Finding the Lowest Common Multiple of Two Numbers

Suppose you have a table that contains two columns, Number1 and Number2, and you want to find the lowest common multiple of these numbers. Here's how you can do it using the GCD function:

1. Create a new measure in the Power BI desktop.

2. In the formula bar, enter the following formula:


(Number1*Number2)/GCD(Number1,Number2)


3. Replace "Number1" and "Number2" with the appropriate column or measure names that contain the numbers you want to find the GCD of.

4. Name the measure something descriptive, such as "LCM of Numbers".

5. Press Enter to create the measure.

The measure will now calculate the lowest common multiple of the numbers in the specified columns.

Example 3: Simplifying Fractions

Suppose you have a table that contains two columns, Numerator and Denominator, and you want to simplify the fractions represented by these numbers. Here's how you can do it using the GCD function:

1. Create a new measure in the Power BI desktop.

2. In the formula bar, enter the following formula:


DIVIDE(Numerator,GCD(Numerator,Denominator))&”/”&DIVIDE(Denominator,GCD(Numerator,Denominator))


3. Replace "Numerator" and "Denominator" with the appropriate column or measure names that contain the numbers you want to find the GCD of.

4. Name the measure something descriptive, such as "Simplified Fraction".

5. Press Enter to create the measure.

The measure will now simplify the fractions in the specified columns.

The GCD function in Power BI is a powerful tool that allows you to find the greatest common divisor of two or more numbers. With this function, you can find the lowest common multiple of two or more numbers, simplify fractions, and perform other useful calculations. By following the steps outlined in this article, you can start using the GCD function in your Power BI reports and gain deeper insights into your data.

Power BI DAX 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)

Copyright, G Com Solutions Ltd, 2024.
Tower Bridge Business Centre, 46-48 East Smithfield, London E1W 1AW
0800 998 9248   |   9:00 a.m. till 5:30 p.m.

Connect With Me: