Forum Discussion

Susan513's avatar
Susan513
Helper II
1 year ago
Solved

Roll up average per 2 categories- custom column

I am looking to get the average SPI per project, per bucket and put that value in the summary row - this is the row with the same task name as the bucket. I am looking to put the data into a Gantt chart - so prefer to utilize this in a custom column if at all possible.

 

I need to isolate the project, then group the buckets, return the average per bucket, and put this value in the project row where the bucket name is the task name. I am trying to break it down, but just learning and could use some help. I am not sure why Microsoft doesn't include this ability in Project Web any longer.

 

Sample data:

This is the result section I am trying to calculate. I have manually done the SPI average calculations in excel:

ProjectBucketsTask NameSPICode needed:
AppleInitiationInitiation0.99Average of Apple Initiation task SPI
PearInitiationInitiation0.89Average of Pear Initiation task SPI
BananaInitiationInitiation0.57Average of Banana Initiation task SPI
ApplePlanningPlanning0.94Average of Apple Planning task SPI
PearPlanningPlanning0.72Average of Pear Planning task SPI
BananaPlanningPlanning0.77Average of Banana Planning task SPI
AppleExecutionExecution Average of Apple Execution task SPI
PearExecutionExecution Average of Pear Execution task SPI
BananaExecutionExecution Average of Banana Execution task SPI

 

This is the additional data (same query)  - where the averages are coming from:

ProjectBucketsTask NameSPI
AppleInitiationTask 10.98
PearInitiationTask 10.80
BananaInitiationTask 10.40
ApplePlanningTask 10.99
PearPlanningTask 10.50
BananaPlanningTask 10.89
AppleExecutionTask 1 
PearExecutionTask 1 
BananaExecutionTask 1 
AppleInitiationTask 21.00
PearInitiationTask 20.88
BananaInitiationTask 20.45
ApplePlanningTask 20.97
PearPlanningTask 20.67
BananaPlanningTask 20.54
AppleExecutionTask 2 
PearExecutionTask 2 
BananaExecutionTask 2 
AppleInitiationTask 30.99
PearInitiationTask 30.98
BananaInitiationTask 30.87
ApplePlanningTask 30.85
PearPlanningTask 30.99
BananaPlanningTask 30.88
AppleExecutionTask 3 
PearExecutionTask 3 
BananaExecutionTask 3 

 

All this data is in one query in Power BI named PW Tasks w/ SPI

 

Appreciate any insight. It seems I need to group by project, then group by bucket, then calculate the average. I am just not certain best way to do this or if possible in a custom column and then have the visual be the Gantt chart. I feel like a measure would be easier - but not sure I can use the data in a Gantt if a measure is used.

  • Hi Susan513, check this:

     

    Output

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdJPC4IwGMfxtyI7i8z9ye1Y0KGbh27DwwiJkSwpg15+o8dCxT0TLxO+8BsfNYbs+75rSU5O3g3ODu7uw8vZPm9ZGQ600Io0uSF1ax9Ipei3OlgfHqQT0P1G68567/x1Mamnk+uNXAyuV0rP5o7v9vJaXiqbjiHFfwpp4pgsHMqCUhyTwa1VChM6IVFMiHSFYUKzq3BMqKTAMVkSk23AZBsw+cpvEq2SmNCpCsUcI4lhzq4VxeTTbxzF5ElMvgFzbJoP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, Buckets = _t, #"Task Name" = _t, SPI = _t]),
        ChangedType = Table.TransformColumnTypes(Source,{{"SPI", type number}}, "en-US"),
        GroupedRows = Table.Group(ChangedType, {"Project", "Buckets"}, {{"T", each _{0} & [Task Name = [Buckets]{0}, SPI = List.Average([SPI])] , type table}}),
        CombinedT = Table.FromRecords(GroupedRows[T], Value.Type(Table.FirstN(ChangedType, 0)))
    in
        CombinedT

4 Replies

  • Temporary solution: I made a copy of the query, grouped by project and bucket. Then I can show the average for the SPI field. I am not a fan of duplicating a query essentially, but I believe this is going to give me the correct data for now.

  • dufoq3's avatar
    dufoq3
    Community Champion

    Hi Susan513, check this:

     

    Output

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdJPC4IwGMfxtyI7i8z9ye1Y0KGbh27DwwiJkSwpg15+o8dCxT0TLxO+8BsfNYbs+75rSU5O3g3ODu7uw8vZPm9ZGQ600Io0uSF1ax9Ipei3OlgfHqQT0P1G68567/x1Mamnk+uNXAyuV0rP5o7v9vJaXiqbjiHFfwpp4pgsHMqCUhyTwa1VChM6IVFMiHSFYUKzq3BMqKTAMVkSk23AZBsw+cpvEq2SmNCpCsUcI4lhzq4VxeTTbxzF5ElMvgFzbJoP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, Buckets = _t, #"Task Name" = _t, SPI = _t]),
        ChangedType = Table.TransformColumnTypes(Source,{{"SPI", type number}}, "en-US"),
        GroupedRows = Table.Group(ChangedType, {"Project", "Buckets"}, {{"T", each _{0} & [Task Name = [Buckets]{0}, SPI = List.Average([SPI])] , type table}}),
        CombinedT = Table.FromRecords(GroupedRows[T], Value.Type(Table.FirstN(ChangedType, 0)))
    in
        CombinedT
    • Susan513's avatar
      Susan513
      Helper II

      Thank you for putting this together - it doesn't seem to work in a custom column and I am not able to utilize the link to 'learn how to use'