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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
arpitkumar2310
Advocate II
Advocate II

show numbers as fraction

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

1 ACCEPTED SOLUTION
hugoberry
Responsive Resident
Responsive Resident

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))

View solution in original post

7 REPLIES 7
hugoberry
Responsive Resident
Responsive Resident

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))

Anonymous
Not applicable

Hi there, I have been using this DAX measure and it is working perfectly but I am getting a number like this for a value that should be 15/26. 

guruguruguru_0-1625580668266.png

Also, I would like it to say, for example 2/2 or 5/5 instead of 1/1 in the case of a whole number. How do I do this? 

 

Thanks so much in advance. 

Hi @hugoberry,

 

Thank you so much!! That was amazing.

Datatouille
Solution Sage
Solution Sage

Hi @arpitkumar2310

 

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.

@Datatouille:

 

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.

Hi @arpitkumar2310,

 

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.Smiley Happy

 

Regards

iHi @v-ljerr-msft,

 

Sure. Thank you.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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