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
Justair07
Resolver I
Resolver I

Divide Sum of Values in Visual Table

Hi,

 

This one really has me stumped 😞

 

I have two valuse I need to divide (RunHrs/DownHrs). Both valuse are sums from my data source. I tried something silly before I realized why it wouldn't work. I tried to add a custom column dividing the numbers in the query table. But obviously this won't work because the two valuse are sums and there is never a RunHrs and DownHrs on the same record so it's always divided by 0 or 0 is divied by a number.

 

This doesn't have to be displayed in a table, I figured it would be easier for me to display in a table.

 

Any help is much appreciated.

 

Thank you

 

Table.JPG

 

 

1 ACCEPTED SOLUTION

Hi @Justair07,

 

You are adding a column to your data table, you need to add a measure this will then be calculated based on context and return the value you need.

 

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

6 REPLIES 6
MFelix
Super User
Super User

Hi @Justair07,

 

You just need to had the following measure to your model:

RunPerc = SUM(Table[RunHrs]) / SUM(Table[DownHrs])

This is based that your table has two different columns on for Run and another for Down.

 

If your table as a classification to make the difference between RunHrs and DownHrs you need to have something like this:

RunPerc = CALCULATE(SUM(Table[Hours]); Table[HoursType] = "RunHrs")/CALCULATE(SUM(Table[Hours]); Table[HoursType] = "DownHrs")

Change the name of the columns with the ones from your table.

 

If any of this examples doesn't fit your model please share the setup of your table to calculate the sum of hours.

 

Regards,

MFelix

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix

 

Thank you for the reply.  Your 2nd solution is more applicable, however I'm getting an error after each semi colon (see 1st image).

 

Just to take another shot, I created two custom columns, one for DownHrs and one for RunHrs then used your first solution. But the math isn't quite right (see 2nd image).

Perc2.JPGPerc1.JPG

 

@MFelix

 

The math isn't what I would have expected. In the 1st image you can see my attempt just to see if the math was adding up which it isn't. 12.98 / 11.02 = 1.18 and the number returning is 6.49.

 

In the 2nd and 3rd pictures you can see my results from the 2nd solution you suggested (comma instead of semi colon).Pic1.JPGPic2.JPGPic3.JPG

Hi @Justair07,

 

You are adding a column to your data table, you need to add a measure this will then be calculated based on context and return the value you need.

 

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix

 

Percection! Thank you sir.

Replace the semicolon by a comma it has to do with regional settings my dax separstor is semicoloon.

Regards,
MFelix

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.