Forum Discussion
Multiple column slicer that affects all visuals (date based)
- Anonymous5 years ago
Hi untalbob ,
Here's a workaround. You can create a new table with a column dedicated to the slicer. And there is no relationship between the new table and the main table.
Create a calculated column in the main table.
Week = YEAR([Date])*1000+WEEKNUM([Date],2)Then you can create the measure as follows.
Value1 = SWITCH ( SELECTEDVALUE ( Slicer[Category] ), "Year to date", TOTALYTD ( SUM ( 'Table'[Value] ), 'Table'[Date] ), "Month to date", TOTALMTD ( SUM ( 'Table'[Value] ), 'Table'[Date] ), "Last Month", CALCULATE ( SUM ( 'Table'[Value] ), DATESINPERIOD ( 'Table'[Date], TODAY (), -1, MONTH ) ), "Current Month", CALCULATE ( SUM ( 'Table'[Value] ), DATESINPERIOD ( 'Table'[Date], TODAY (), 0, MONTH ) ), "Next Month", CALCULATE ( SUM ( 'Table'[Value] ), DATESINPERIOD ( 'Table'[Date], TODAY (), 1, MONTH ) ), "Last Week", CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [Week] = YEAR ( TODAY () ) * 10000 + WEEKNUM ( TODAY (), 2 ) - 1 ) ), "Current Week", CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [Week] = YEAR ( TODAY () ) * 10000 + WEEKNUM ( TODAY (), 2 ) ) ), "Next Week", CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [Week] = YEAR ( TODAY () ) * 10000 + WEEKNUM ( TODAY (), 2 ) + 1 ) ) )Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi untalbob ,
Here's a workaround. You can create a new table with a column dedicated to the slicer. And there is no relationship between the new table and the main table.
Create a calculated column in the main table.
Week = YEAR([Date])*1000+WEEKNUM([Date],2)
Then you can create the measure as follows.
Value1 =
SWITCH (
SELECTEDVALUE ( Slicer[Category] ),
"Year to date", TOTALYTD ( SUM ( 'Table'[Value] ), 'Table'[Date] ),
"Month to date", TOTALMTD ( SUM ( 'Table'[Value] ), 'Table'[Date] ),
"Last Month",
CALCULATE (
SUM ( 'Table'[Value] ),
DATESINPERIOD ( 'Table'[Date], TODAY (), -1, MONTH )
),
"Current Month",
CALCULATE (
SUM ( 'Table'[Value] ),
DATESINPERIOD ( 'Table'[Date], TODAY (), 0, MONTH )
),
"Next Month",
CALCULATE (
SUM ( 'Table'[Value] ),
DATESINPERIOD ( 'Table'[Date], TODAY (), 1, MONTH )
),
"Last Week",
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
'Table',
[Week]
= YEAR ( TODAY () ) * 10000
+ WEEKNUM ( TODAY (), 2 ) - 1
)
),
"Current Week",
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( 'Table', [Week] = YEAR ( TODAY () ) * 10000 + WEEKNUM ( TODAY (), 2 ) )
),
"Next Week",
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
'Table',
[Week]
= YEAR ( TODAY () ) * 10000
+ WEEKNUM ( TODAY (), 2 ) + 1
)
)
)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.