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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
panchinxd
Frequent Visitor

How to calculate porcentage

Hey guys! i am pretty Sure this so easy for you! but i need to calculate a porcentage! having this table on Power BI

AB
512.5
1220.1
1011.5
Total 27Total 44.1


So i need to divide every single one of B / the total of A for example:

      12.5 / 27 =
      20.1 / 27 =

Been using Porcentage = divide ( B ; sum(A))

Something like that, not writting all the formula, Thank you so much! this is my first post 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@panchinxd 

Okay, change your formula to use ALLSELECTED instead of ALL and see if your filters work.

So:

DIVIDE(SUM(Hoja1[Mora Real];CALCULATE(SUM(Hoja1[SALDOCAP.]);ALLSELECTED(Hoja1))
)
 
Let me know if that works.

View solution in original post

14 REPLIES 14
panchinxd
Frequent Visitor

Captura.PNG

While im using 

% Mora =
DIVIDE(Hoja1[Mora Real];CALCULATE(SUM(Hoja1[SALDOCAP.]);ALL(Hoja1[SALDOCAP.]))
)

i am getting those incorrects results
Anonymous
Not applicable

Set up your measure like this:

Annotation 2019-12-12 095251.png

 

So in your case it would be:

DIVIDE(SUM(Hoja1[Mora Real];CALCULATE(SUM(Hoja1[SALDOCAP.]);ALL(Hoja1))
)
 

---
Please hit the "Accept as Solution" button if my post answered your question! If my post was helpful please consider giving it a "Thumbs Up."

thank you for helping me!

i have seen that i am using some date filters, and that filter is affecting me if i take that filter off, is giving me the exact result! but i dont know how to apply it to the code you just gave me

Anonymous
Not applicable

On your visual, select "New Measure"

Annotation 2019-12-12 124752.png

Give your measure a name, or just leave it called Measure, then enter the formula: (I removed some of the noise in my model so this example looks a little cleaner)

Annotation 2019-12-12 125124.png

Then add the measure to your visual, in this case I'm adding it to the table: (I also selected the measure and increased the number of decimal places)

Annotation 2019-12-12 125443.png

 

---
Please hit the "Accept as Solution" button if my post answered your question! If my post was helpful please consider giving it a "Thumbs Up."

Captura.PNG

 

Pretty sure im on that way! the date filter is in 

Captura 2.PNG

Is in spanish but it is a date! haha

Anonymous
Not applicable

If you remove the date filter, do you get the correct percentages?

Captura.PNG

Actually i have 2 filters, "Estado" is the other one! when i remove both of them, i get the correct porcentages

Anonymous
Not applicable

@panchinxd 

Okay, change your formula to use ALLSELECTED instead of ALL and see if your filters work.

So:

DIVIDE(SUM(Hoja1[Mora Real];CALCULATE(SUM(Hoja1[SALDOCAP.]);ALLSELECTED(Hoja1))
)
 
Let me know if that works.

OMMG! YEEEES Thank you so much! really appreciate your time

Anonymous
Not applicable

What's happening is that the ALL portion of the formula is resulting in the denominator for your percentage always being the same. So when you apply a filter it changes the value of [Mora Real] being used, but the denominator continues to be the sum of [SALDOCAP] across the entire table.

v-xicai
Community Support
Community Support

Hi @panchinxd ,

 

You can create measure or column like DAX below.

 

Measure1 = DIVIDE(SUM('Table'[B]),CALCULATE(SUM('Table'[A]),ALL('Table')))

 

Column1 = DIVIDE('Table'[B],CALCULATE(SUM('Table'[A]),ALL('Table')))

 

Best Regards,

Amy

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hey Amy!

Thanks for your support but, i have this report filter by date, so i am just showing some specific date, thats why i am not getting the specific porcentage (i think) it gives me a little bit more, not sure if filters are afected by this code, or i have to add another code

Anonymous
Not applicable

You can add a Custom Column in the Query Editor. Select the first column then press / then select the second column then put *100 at the end. Afterwards, change the column type to %

 

Annotation 2019-12-11 154551.png

 

---
Please hit the "Accept as Solution" button if my post answered your question! If my post was helpful please consider giving it a "Thumbs Up."

Thank You for answer me!

What i have seen, is that it does not divide the Sum of A, it does it individually! for example B / A and i need B / sum(A)

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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