Forum Discussion
gomezc73
Helper V
3 years agoCreate a comparative Matrix with data by year filtered with two slicers
Hi, I am having trouble trying to create a matrix with the data filtered by two slicers (to compare the data by year). In other words, my data have a monthly summary of sales by product/y...
- Anonymous3 years ago
Hi gomezc73 ,
I suggest you to inactive all relationships betwen two dimyear tables and your data table.
Data model:
Measure:
Measure = VAR _RecentYear = SELECTEDVALUE ( 'Year'[Year 1] ) VAR _PreviousYear = SELECTEDVALUE ( 'Year 2'[Year 2] ) VAR _Amount = CALCULATE ( SUM ( 'Table'[Amount] ), FILTER ( 'Table', 'Table'[Year] IN { _PreviousYear, _RecentYear } ) ) VAR _Part1 = CALCULATE ( SUM ( 'Table'[Amount] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Month] ), 'Table'[Year] = _RecentYear ) ) VAR _Part2 = CALCULATE ( SUM ( 'Table'[Amount] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Month] ), 'Table'[Year] = _PreviousYear ) ) RETURN IF ( HASONEVALUE ( 'Table'[Year] ), _Amount, _Part2 - _Part1 )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
3 years agoNot applicable
Hi gomezc73 ,
I suggest you to inactive all relationships betwen two dimyear tables and your data table.
Data model:
Measure:
Measure =
VAR _RecentYear =
SELECTEDVALUE ( 'Year'[Year 1] )
VAR _PreviousYear =
SELECTEDVALUE ( 'Year 2'[Year 2] )
VAR _Amount =
CALCULATE (
SUM ( 'Table'[Amount] ),
FILTER ( 'Table', 'Table'[Year] IN { _PreviousYear, _RecentYear } )
)
VAR _Part1 =
CALCULATE (
SUM ( 'Table'[Amount] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Month] ), 'Table'[Year] = _RecentYear )
)
VAR _Part2 =
CALCULATE (
SUM ( 'Table'[Amount] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Month] ), 'Table'[Year] = _PreviousYear )
)
RETURN
IF ( HASONEVALUE ( 'Table'[Year] ), _Amount, _Part2 - _Part1 )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
gomezc73
Helper V
3 years agoIt worked fine. thank you very much!!. the only change i did was change hasonevalue by Inscope and worked perfect. I really appreciate your help