Forum Discussion
Calculated table with summarized working time
- 3 years ago
Hi IvanS
Do you must use DAX to split the "Team Composition" column? If so, you may refer to this article: Split a Delimited Row into Multiple Rows using DAX Queries – Some Random Thoughts (sqljason.com)
Otherwise I would prefer to use Power Query as it would be easier. Here is what I do in Power Query Editor:
First split "Team Composition" column by delimiter comma into Rows.
Perform "Trim" on the new "Team Composition" column to remove any additional leading or ending spaces.
Apply the change to Power BI Desktop, then create a calculated table with below DAX.
Table 2 = VAR _table = FILTER('Table','Table'[Close Date]>BLANK()) RETURN FILTER( DISTINCT( UNION( SELECTCOLUMNS(_table,"Task ID",'Table'[Task ID],"Close Date",'Table'[Close Date],"Name",'Table'[Task Owner]), SELECTCOLUMNS(_table,"Task ID",'Table'[Task ID],"Close Date",'Table'[Close Date],"Name",'Table'[Team Composition]) ) ), [Name] <> BLANK() )Add a calculated column into above 'Table 2'.
Time of work = VAR _memberCount = COUNTROWS(FILTER('Table 2','Table 2'[Task ID] = EARLIER('Table 2'[Task ID]))) VAR _totalMinutes = CALCULATE(MAX('Table'[Total working time (minutes)]),'Table'[Task ID] = EARLIER('Table 2'[Task ID])) RETURN DIVIDE(_totalMinutes,_memberCount)I have attached the sample file. Hope it helps.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi IvanS
Do you must use DAX to split the "Team Composition" column? If so, you may refer to this article: Split a Delimited Row into Multiple Rows using DAX Queries – Some Random Thoughts (sqljason.com)
Otherwise I would prefer to use Power Query as it would be easier. Here is what I do in Power Query Editor:
First split "Team Composition" column by delimiter comma into Rows.
Perform "Trim" on the new "Team Composition" column to remove any additional leading or ending spaces.
Apply the change to Power BI Desktop, then create a calculated table with below DAX.
Table 2 =
VAR _table = FILTER('Table','Table'[Close Date]>BLANK())
RETURN
FILTER(
DISTINCT(
UNION(
SELECTCOLUMNS(_table,"Task ID",'Table'[Task ID],"Close Date",'Table'[Close Date],"Name",'Table'[Task Owner]),
SELECTCOLUMNS(_table,"Task ID",'Table'[Task ID],"Close Date",'Table'[Close Date],"Name",'Table'[Team Composition])
)
),
[Name] <> BLANK()
)
Add a calculated column into above 'Table 2'.
Time of work =
VAR _memberCount = COUNTROWS(FILTER('Table 2','Table 2'[Task ID] = EARLIER('Table 2'[Task ID])))
VAR _totalMinutes = CALCULATE(MAX('Table'[Total working time (minutes)]),'Table'[Task ID] = EARLIER('Table 2'[Task ID]))
RETURN
DIVIDE(_totalMinutes,_memberCount)
I have attached the sample file. Hope it helps.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
- IvanS3 years agoHelper V
This worked like a charm! Thank you 🙂