Forum Discussion

Sakamoto_S's avatar
Sakamoto_S
Frequent Visitor
5 years ago

Hierarchy - Column

 

Epic = Grand Parent, Task = Parent and Sub-task = child. I need help. I am newbie and trying to create a new column("Total Hours") that will show the sum of Sub-task hours to epic row. See example above in red for your reference. 

6 Replies

  • v-xiaotang's avatar
    v-xiaotang
    Community Support

    Hi @

    -

    Try this,

    Total Hours =
    VAR total_subtask =
        CALCULATE (
            SUM ( 'Table'[Hours] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Issue-Type] = "Sub-task" )
        )
    RETURN
        IF ( SELECTEDVALUE ( 'Table'[Issue-Type] ) = "Epic", total_subtask, BLANK () )

    Result:

    See sample file attached below.

     

    Best Regards,

    Community Support Team _ Tang

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

      • v-xiaotang's avatar
        v-xiaotang
        Community Support

        Hi Sakamoto_S 

        -

        Thanks for your reply.

        But it would be better for the precondition to be given at the beginning. Because the solutions are different.🤣

        -

        create the measure firstly:

        _IssueID = LEFT(SELECTEDVALUE('Table'[Issue ID]),1)

        then, create the measure,

         

        Total Hours 2 =
        VAR total_subtask =
            CALCULATE (
                SUM ( 'Table'[Hours] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[Issue-Type] = "Sub-task"
                        && LEFT ( SELECTEDVALUE ( 'Table'[Issue ID] ), 1 ) = [_IssueID]
                )
            )
        RETURN
            IF (
                SELECTEDVALUE ( 'Table'[Issue-Type] ) = "Epic"
                    && LEFT ( SELECTEDVALUE ( 'Table'[Issue ID] ), 1 ) = [_IssueID],
                total_subtask,
                BLANK ()
            )

         

         

        Result:

        Hope it helps!

        See sample file attached below.

         

        Best Regards,

        Community Support Team _ Tang

        If this post helps, please consider Accept it as the solutionāœ”ļø to help the other members find it more quickly.