Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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!
Solved! Go to Solution.
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:
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.
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:
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.
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!!
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.
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
12 | |
11 | |
7 | |
6 |