Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

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
  • Anonymous's avatar
    Anonymous
    8 years ago

    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's avatar
    Anonymous
    8 years ago

    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.

23 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Would a simple measure such as this do the trick:

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

      The results returned are all zero :smileysad:

      • Anonymous's avatar
        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.