Forum Discussion
How to summarize values with a Matrix when data is in three different tables?
- Anonymous1 year ago
Hi Anonymous
Please try this measure:
MEASURE = VAR _PK = SELECTEDVALUE ( 'Sub-Tasks'[Parent Key] ) VAR _K = SELECTEDVALUE ( 'Sub-Tasks'[Key] ) VAR _vtable = SELECTCOLUMNS ( FILTER ( CROSSJOIN ( ALLSELECTED ( 'Sub-Tasks' ), ALLSELECTED ( 'Time Spent' ) ), 'Sub-Tasks'[Key] = 'Time Spent'[Key] ), "__Key", 'Sub-Tasks'[Parent Key], "__Hours", 'Time Spent'[Hours] ) RETURN IF ( ISINSCOPE ( 'Sub-Tasks'[Key] ), CALCULATE ( SUM ( 'Time Spent'[Hours] ), FILTER ( ALLSELECTED ( 'Time Spent' ), 'Time Spent'[Key] = _K ) ), CALCULATE ( SUM ( 'Time Spent'[Hours] ), FILTER ( ALLSELECTED ( 'Time Spent' ), 'Time Spent'[Key] = _PK ) ) + SUMX ( FILTER ( _vtable, [__Key] = _PK ), [__Hours] ) )Then create a matrix with the field [Parent Key]and [Key] from 'Sub-Tasks', the result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello,
From my understanding of the data you presented, and based on the Star Model, your "Time Spent" table is your fact table, the Stories and Sub-Task tables are your dimension tables.
That is to say, your stories table should link to Time Spent as One to Many, and your Sub-Task should link to Time Spent as One to Many. All based off of the Key column.
How then would I get the hierarchy to display in the Matrix since there isn't a relationship between Sub-Task[Parent Key] and Stories[Key]?