Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
noble10
Frequent Visitor

Ratio calculation

Hello 

 

Can someone please show me a measure of how to calculate the ratio of two numbers. The screenshot below shows how I completed the ratio in excel but how do I achieve this through power bi dax measure?  Thanks!

 

noble10_0-1634855059079.png

 

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @noble10 

According to your description, I can clearly understand your requirement, you can try to create a calculated column like this:

Ratio =

var _GCD=GCD([item],[product])

return

DIVIDE([product],_GCD)&":"&DIVIDE([item],_GCD)

 

And you can get what you want, like this:

vrobertqmsft_0-1635491363462.png

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @noble10 

According to your description, I can clearly understand your requirement, you can try to create a calculated column like this:

Ratio =

var _GCD=GCD([item],[product])

return

DIVIDE([product],_GCD)&":"&DIVIDE([item],_GCD)

 

And you can get what you want, like this:

vrobertqmsft_0-1635491363462.png

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @noble10 

Try this:

 

Measure = 
VAR _A =
    MAX ( [Production] ) // X in the excel formula
VAR _B =
    MAX ( [Item] ) // Y in the excel formula
VAR _GCD =
    GCD ( _A_B )
RETURN
    _A / _GCD & ":" & _B / _GCD

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

@VahidDM  

 

Thank you for your help. Unfortunately that formula above did not work. Production and Items are measures that I have created. I got the error message below. 

noble10_0-1634918832520.png

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors