cancel
Showing results for
Did you mean:
Frequent Visitor

## show numbers as fraction

How to show a number in a "New Measure" as a Fraction or Ratio?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Member

## Re: show numbers as fraction

The general algorithm would be for the example that you've given.

Given : 2.5

1. Represent the number as a fraction : 25/10

2. Find GCD(25,10) =  5

3. Divide both the numerator and denominator by GCD=5

Result: 5/2

It's up to you  to choose the precision. Here is my take on some DAX

Fraction =
var given=2.5
var precision=100000
return (given*precision/GCD(given*precision,precision))&"/"&(precision/GCD(given*precision,precision))

6 REPLIES 6
Established Member

## Re: show numbers as fraction

What do you mean exactly ?

You can use the symbol "/" or, even better, the DAX function Divide in your measures.

You can then display the measure as percentage in 'Modeling' > Formatting.

Frequent Visitor

## Re: show numbers as fraction

Currently I am using it as

Measure = format(2.5,"0.0%")

Which will display it as 250.0% but I want it to display it as 5 / 2 or 5 : 2.

Super Contributor

## Re: show numbers as fraction

As there is no option to set number format for a measure to Fraction in 'Modeling' > Formatting currently, I would suggest you to submit your requirement on Power BI Ideas and vote it up to improve Power BI on this feature.

Regards

Frequent Visitor

## Re: show numbers as fraction

iHi @v-ljerr-msft,

Sure. Thank you.

Highlighted
Member

## Re: show numbers as fraction

The general algorithm would be for the example that you've given.

Given : 2.5

1. Represent the number as a fraction : 25/10

2. Find GCD(25,10) =  5

3. Divide both the numerator and denominator by GCD=5

Result: 5/2

It's up to you  to choose the precision. Here is my take on some DAX

Fraction =
var given=2.5
var precision=100000
return (given*precision/GCD(given*precision,precision))&"/"&(precision/GCD(given*precision,precision))

Frequent Visitor

## Re: show numbers as fraction

Hi @hugoberry,

Thank you so much!! That was amazing.

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 218 members 2,363 guests
Recent signins: