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
heathernicole
Continued Contributor
Continued Contributor

Calculating Percentage of total (not using new QuicCalc Feature) - getting a NaN or 0 for percentage

I am trying to calculate the percentage of total manually in regards to Credit Vs. Total Sales.

 

For Example:

 

Credits for June: ($100)

Invoiced for June: $10,000

 

Unless I'm missing something the basic calculation for this would be

 

(Credits  / Invoiced) * 100

 

Here is my formula in Power BI:

 

Credit Percentage = CALCULATE(DIVIDE(SUM('SALES DETAILS'[Credit Amount]), SUM('SALES DETAILS'[Invoice Amount])) * 100)

The data is from Quickbooks (which is always seems to be a pain to work with due to the database structure).

 

For invoice amount, my data looks like this: 

Invoiced Data.png

 

Credit Raw data looks like this:

Credit data.png

 

 

 

I've tried every combination of this type. I either get 0.00 or Nan. Every now and then I'll get a funky number.

 

This seems simple enough... I can't figure out why it won't just work. Any ideas or tips would be extremely helpful. 🙂 

 

Thanks in advance!

 

~H

 

~heathernicoale
1 ACCEPTED SOLUTION

Figured it out!!! 😄 

 

Instead of Credit% being a column it needs to be a MEASURE. (this deserves a little bit of a palm slap). 

 

I had tried a measure before but I may not have had the calculation right. See below. 🙂 

 

Correct Credit Percentage.png

 

@Vvelarde

~heathernicoale

View solution in original post

7 REPLIES 7
heathernicole
Continued Contributor
Continued Contributor

@Vvelarde 

 

I tried the code that you sent - Credit% = DIVIDE((SUM('Sales Details'[Credit Amount])),(SUM('Sales Details'[Invoice Amount])))*100

 

And I got an incorrect value -  (-65.86). I have no idea how it's coming up with that number. 😕

 

Here are the figures I'm testing with:

Credit Percentage Example.png

 

It should calculate to be - 1.55% as the end result

~heathernicoale

Figured it out!!! 😄 

 

Instead of Credit% being a column it needs to be a MEASURE. (this deserves a little bit of a palm slap). 

 

I had tried a measure before but I may not have had the calculation right. See below. 🙂 

 

Correct Credit Percentage.png

 

@Vvelarde

~heathernicoale

Smiley Very Happy Smiley Very Happy Smiley LOL

 

@heathernicole I'm surprised you didn't add an appropriate picture to accompany the post above (like you always do Smiley Very Happy)

heathernicole
Continued Contributor
Continued Contributor

@Sean Smiley Very Happy  I ended up taking out the multiply by 100 so I could get just the initial decimal figure then changed the data type to percentage. That worked a lot better. 🙂 

 

Final credit Report.png

 

~heathernicoale
heathernicole
Continued Contributor
Continued Contributor

@Vvelarde - Hello! 🙂 I'm getting emails that show your responses - but I can't see them when I come to this post - not sure why?

 

~heathernicoale
ianbarker
Helper III
Helper III

Something like this should give you what you need:

 

Credit Percentage = CALCULATE(SUM(Table[Credit Amount])/SUM(Table[Invoice Amount]))

 

Stick *-1 on the end if you want the percentage to appear positive.

Vvelarde
Community Champion
Community Champion

hi @heathernicole

 

Credit% = Divide(Sum('Sales Details[Credit Amount]);(SUM('Sales Details[Invoice Amount])))*100




Lima - Peru

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.