Forum Discussion
elzahy
3 years agoNew Member
How to create fraction based on 2 calculated columns
Hello,
I would like to display fraction in name card based on 2 calculated columns.
fraction=
var given= 'table'[R]
var precision='table'[T]
return (given*precision/GCD(given*precision,precision))&"/"&(precision/GCD(given*precision,precision))
However, my result is 4.0032251562185/4965
My desire result should be 4/4965
My desire result should be 4/4965
Anyone can help?
Thank you
- Anonymous3 years ago
Hi elzahy ,
You can try the following dax:
Column = var given= 'table'[R] var precision='table'[T] var value1=given*precision/GCD(given*precision,precision) var value2=precision/GCD(given*precision,precision) return FORMAT(value1,"$#,##0") &"/"& value2Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- lbendlin
Super User
DAX is lousy at precision math.
Choosing Numeric Data Types in DAX - SQLBI
Understanding numeric data type conversions in DAX - SQLBI
Change your order of calculation.
- AnonymousNot applicable
Hi elzahy ,
You can try the following dax:
Column = var given= 'table'[R] var precision='table'[T] var value1=given*precision/GCD(given*precision,precision) var value2=precision/GCD(given*precision,precision) return FORMAT(value1,"$#,##0") &"/"& value2Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.