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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
yasbos
Resolver II
Resolver II

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 2
amitchandak
Super User
Super User

@yasbos , A new column with Sumx and table TotTimeTask, will sum up all the data of that table in column

Try groupby with current group

 

refer

https://medium.com/@amitchandak/power-bi-power-query-vs-dax-append-and-summarize-data-233f173d0839

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

 

I get the below error.
function group by scalar expressions have to be aggregation functions over currentgroup(). the expression of each aggregation has to be either a constant or directly reference the columns in currentgroup()

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Kudoed Authors