Forum Discussion
Dual Slicing
- Anonymous1 year ago
Hi ianallen13V2 ,
Maybe you can try formula like below:
Current= VAR sel_year = SELECTEDVALUE ( 'Date'[Year] ) VAR sel_month = SELECTEDVALUE ( 'Date'[Month] ) RETURN IF ( ISFILTERED ( 'Table' ), CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( ALL('Table'), YEAR ( 'Table'[Date] ) = sel_year && MONTH ( 'Table'[Month] ) = sel_month ) ), CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( ALL('Table'), YEAR ( [Date] ) = YEAR ( TODAY () ) && MONTH ( [Date] ) = MONTH ( TODAY () ) ) ) )Previous= VAR sel_year = SELECTEDVALUE ( 'Date'[Year] ) VAR sel_month = SELECTEDVALUE ( 'Date'[Month] ) RETURN IF ( ISFILTERED ( 'Table' ), CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( ALL('Table'), YEAR ( 'Table'[Date] ) = sel_year && MONTH ( 'Table'[Month] ) = sel_month ) ), CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( ALL('Table'), YEAR ( [Date] ) = YEAR ( TODAY () ) - 1 && MONTH ( [Date] ) = MONTH ( TODAY () ) ) ) )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi ianallen13V2
Pls follow below steps
- create measures for Current and Previous Periods by using the below measure
CurrentMonthNumber =
CALCULATE(SUM('Table'[Value]),
FILTER('DateTable',
'DateTable'[Year] = YEAR(TODAY()) &&
'DateTable'[Month] = MONTH(TODAY())))PreviousMonthNumber =
CALCULATE(SUM('Table'[Value]),
FILTER('DateTable',
'DateTable'[Year] = YEAR(TODAY()) - 1 &&
'DateTable'[Month] = MONTH(TODAY())) - Create dynamic measures that respond to the slicer selections. as per below measures
SelectedMonthValues =
CALCULATE(SUM('Table'[Value]),
FILTER('DateTable',
'DateTable'[Year] = SELECTEDVALUE('DateTable'[Year]) &&
'DateTable'[Month] = SELECTEDVALUE('DateTable'[Month])))SelectedPreviousMonthValues =
CALCULATE(SUM('Table'[Value]),
FILTER('DateTable',
'DateTable'[Year] = SELECTEDVALUE('DateTable'[Year]) - 1 &&
'DateTable'[Month] = SELECTEDVALUE('DateTable'[Month]))) - Then create a bookmark with the slicers set to the current month/year
- Set this bookmark as the default view when the report is opened.
Let me know if it works
Thanks!