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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Dynamic percentage based on attributes applied

I'd like to create a measure that displays a percentage of time-phased labour cost data dependent on the attributes added to a visual. The attributes I want to be able to apply are (I want the ability to apply any number of these attributes to see, for example, things like the percentage of time/cost a given team has spent on a project):

- Project Name

- Resource Name

- Resource Role

- Resource Team Name

- Month & Year

I grouped the data in the table via the Query Editor and added a Total Cost column so the Actual Cost value can be divided by Total Cost to display a percentage, but am stuck on the best measure to create for this. 

Here is a sample of the type of data I'm working with and how it's been grouped:

ResourceNameProjectNameTeamNameRoleMonth & YearStart of MonthSumActualCostTotal Cost
Resource IExample ProjectTeam TRole OJan-20181/01/20185165137480.1
Resource AExample ProjectTeam TRole ONov-20171/11/20175162.5137480.1
Resource BBExample ProjectTeam CRole NJun-20171/06/20175075137480.1
Resource VExample ProjectTeam TRole LDec-20171/12/20175075137480.1
Resource VExample ProjectTeam TRole LDec-20161/12/20165025137480.1
Resource VExample ProjectTeam TRole LMay-20161/05/20164975137480.1
Resource FExample ProjectTeam TRole MDec-20161/12/20164975137480.1
Resource VExample ProjectTeam TRole LSep-20161/09/20164950137480.1
Resource IExample ProjectTeam TRole OApr-20171/04/20174915137480.1
Resource OExample ProjectTeam DRole DAug-20161/08/20164875137480.1
Resource AExample ProjectTeam TRole OSep-20171/09/20174837.5137480.1
Resource IExample ProjectTeam TRole OFeb-20161/02/20164835137480.1
Cost Resource BExample Project Role CJul-20171/07/20174827.611483137480.1
Resource CExample ProjectTeam MRole OJun-20171/06/20174825137480.1
Resource FExample ProjectTeam TRole MJan-20181/01/20184800137480.1
Resource AExample ProjectTeam TRole OJun-20171/06/20174762.5137480.1
Resource VExample ProjectTeam TRole LJul-20161/07/20164725137480.1
Resource FExample ProjectTeam TRole MDec-20171/12/20174725137480.1
Resource FExample ProjectTeam TRole MAug-20171/08/20174700137480.1
Resource RExample Project Role FApr-20161/04/20164625137480.1
Resource FExample ProjectTeam TRole MJan-20171/01/20174500137480.1
Resource BBExample ProjectTeam CRole NAug-20171/08/20174450137480.1
Resource EExample ProjectTeam TRole MMar-20161/03/20164425137480.1
Resource SExample ProjectTeam ARole KOct-20161/10/20164400137480.1
Resource DDExample ProjectTeam TRole ASep-20171/09/20174400137480.1
Resource EExample ProjectTeam TRole MFeb-20181/02/20184400137480.1
Resource AExample ProjectTeam TRole OMar-20171/03/20174375137480.1
Resource FExample ProjectTeam TRole MApr-20171/04/20174350137480.1
Resource VExample ProjectTeam TRole LMar-20161/03/20164325137480.1
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Ok great, the formatting must have been the elusive element.

 

Doing some quick maths:

 

208764.42 / 37968039.17 = 0.005498425.  As a percentage that should be 0.54%.  So that means you are correct in that its 100 times too small, plus the number itself is wrong.

Lets create 2 more measures. 

Numerator = SUM('YourTable'[SumActualCost])
Denominator = SUM('YourTable'[Total Cost])

Bring those into the matix next.  I'm curious what that comes up with.

 

For the reason the reason it doesn't add to 100%, i believe My error is with Total Cost.  Instead of SUM for the Denominator, we should use MAX instead.  This is because you don't actually want to sum up that column.

View solution in original post

Anonymous
Not applicable

No definately not, thats not necessary.  Does your formula now look like?

Simple % = DIVIDE(
     [Numerator],
     [Denominator]
)

Remembering Numerator and Denominator are measures, so we can call them directly in our new Measure.

View solution in original post

23 REPLIES 23
Anonymous
Not applicable

Would a simple measure such as this do the trick:

Simple % = DIVIDE(
     SUM('YourTable'[SumActualCost]),
     SUM('YourTable'[Total Cost])
)
Anonymous
Not applicable

The results returned are all zero Smiley Sad

Anonymous
Not applicable

Where are you putting the measure to be displayed?  What filter contexts are used?  Getting zero in this manner makes me suspect there is another element in play here.

Anonymous
Not applicable

The measure is created within this table. Which was originally two tables, but merged together in the Query Editor and then I used the Group By function and specified these columns, and aggregated the Actual Cost. No filters have been applied. The visual I'm viewing the result in is a table, and I had to specify the Total Cost column to "Don't Summarize".

Anonymous
Not applicable

Just to clarify,  The matrix visual in your screen shot has each item entirely from this single grouped table?

 

What does it look like if you bring the Measure onto your table, so you get a row by row result?

 

Is the table used for the matrix visual the same table referenced by the measure?

Anonymous
Not applicable

I've just changed the Format of the Measure to "Percentage" and now I'm seeing numbers but the total is 0.0087184% (shouldn't this be 100%?) and the row values aren't correct (see screenshot for example). I've tried multiplying the measure by 100 and this seems closer to what it should be, but as you can see below, a percentage for 2.3m is lower than 350k...?

Capture.PNG

 

Anonymous
Not applicable

Ok great, the formatting must have been the elusive element.

 

Doing some quick maths:

 

208764.42 / 37968039.17 = 0.005498425.  As a percentage that should be 0.54%.  So that means you are correct in that its 100 times too small, plus the number itself is wrong.

Lets create 2 more measures. 

Numerator = SUM('YourTable'[SumActualCost])
Denominator = SUM('YourTable'[Total Cost])

Bring those into the matix next.  I'm curious what that comes up with.

 

For the reason the reason it doesn't add to 100%, i believe My error is with Total Cost.  Instead of SUM for the Denominator, we should use MAX instead.  This is because you don't actually want to sum up that column.

Anonymous
Not applicable

I've created those measures, do you want me to replace them in the % measures now? I can't seem to select measures in the formula.

 

The measures now return the same results as follows:

SumActualCost = Numerator

Total Cost (when values aren't aggregated) = Denominator

Anonymous
Not applicable

Excellent.  Try changing your % measure to use the numerator and denominator.  Curious at the result.

Anonymous
Not applicable

When I try to, I get an error saying the column can't be found. Should I make the Numerator and Denominator columns instead?

Anonymous
Not applicable

No definately not, thats not necessary.  Does your formula now look like?

Simple % = DIVIDE(
     [Numerator],
     [Denominator]
)

Remembering Numerator and Denominator are measures, so we can call them directly in our new Measure.

Anonymous
Not applicable

Hi @Anonymous

 

The feedback I've received on this percentage has included a request for it to dynamically change the total value it's using to calculate the percentage based on the slicer selection. Is this possible? 

 

For example, if a specific project has been selected in the slicer, we would want the percentage calculated based on the total cost of that project, showing a percentage split across teams and roles. 

 

Thanks.

Anonymous
Not applicable

 @Anonymous  Have you tested it already with a slicer?  The formula is context driven, so it should correctly respond to any slicers you use.

Anonymous
Not applicable

Yes, applying the slicer currently doesn't change the total value it's calculating from. The percentage should total to 100% on the visual if that was the case.

Capture.PNG

Anonymous
Not applicable

This would likely be an issue with your data and your data relations.

 

All our measure do is sum up the individual rows, for both 'ActualCost' and 'TotalCost'.  The slicers will be adding a context to limit what is contained in both of those summations.

 

As to why it doesn't add to 100%, this will be entirely dependant on how your TotalCost column has had it data populated.  When selecting a subset of the data, yes you will be adding up less TotalCost lines, but i'm unable to say whether that change in context causes some invalidation of your information.

 

Anonymous
Not applicable

Hi

 

I created a new file with only the main table, without any transformations made to it. I added the measures and the same thing still happens. When a slicer is applied, the percentages don't recalculate to show the ratio within that selection. It appears to be hard-coded to the overall total cost rather than being dynamic. Is there a change I could try to the measures formulae?

 

Thanks

Anonymous
Not applicable

The slicers you are using, are they from the same table as the data or are the slicers referencing another table?  Is the table relationships correct to enable your slicers to work?

Anonymous
Not applicable

In the original file (with multiple tables and transformations) the slicer is from the same table as the measures. In the new file there is only one table and no transformations - so the slicer is from the same table as the measures again. 

 

The formula used for Total Cost is:

Original file (where the table has been grouped): Total Cost = SUM('AssignmentTPDS'[SumActualCost])

New file (where the table hasn't been grouped): Total Cost = SUM('Query1'[AssignmentActualCost])

Anonymous
Not applicable

@Anonymous - have you had anymore thoughts on this?

Anonymous
Not applicable

Sorry @Anonymous no I haven't.  As described, it should work.  Based on everything you have put forward, it should work.  There must be another unseen element at play.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.