Forum Discussion

yasbos's avatar
yasbos
Resolver II
2 years ago

Summarizing a second table variable doesn't work right

Good day, friends! In the below code, I'm summarizing the duration per subtask. If the task has no end date, I'm calculating the duration as being the difference between the start date and today's date. 

 

So, the below TotTimeTask table produces a list of TaskID, SubtaskID, Duration

define var TotTimeTask= calculatetable(ADDCOLUMNS(summarize(SubtaskFact,SubtaskFact[TaskID],SubtaskFact[SubtaskID]), "SubtaskDuration"
    ,calculate(if(isblank(average(SubtaskFact[SubtaskEndedOn]))
            ,datediff(average(SubtaskFact[SubtaskStartedOn]),today() ,SECOND)  
            ,sum(SubtaskFact[durationSeconds]))
))
)
The above works fine and shows the correct results.

Here is the problem. Now, I want to summarize the above table at the TaskID only. I Do Addcolumns/Summarize again but leave out the SubTaskID. 
evaluate addcolumns(summarize(vTotTimeTask,SubtaskFact[TaskID]), "TaskDuration",calculate(SUMX(TotTimeTask,[SubtaskDuration])))

 

What the above gives me is the grand total in every row for TaskDuration. I don't understand why!

I can't share the file because it uses tabular direct connection.

Thanks for your help.

2 Replies