Forum Discussion
Timeperiod slicer
- 2 years ago
Hi Anonymous
There is no option to limit selections in the generic slicer.You can create a slicer with similar functionality manually .
Please refer to the linked tutorials :https://www.youtube.com/watch?app=desktop&v=3SmHtNf0QQ0
https://www.youtube.com/watch?v=fKygF7VEJnQ
https://www.youtube.com/watch?v=JLupF1j49wo
If this post helps, then please consider Accepting it as the solution to help the other
members find it more quickly
Thanks for the reply ,
And I apologise for asking silly question , but I'm facing error while creating measure
FilteredData =
SWITCH (
SELECTEDVALUE('SlicerTable'[DateRange]),
"Last Month", CALCULATETABLE(YourData, 'YourData'[Date] >= STARTOFMONTH(TODAY()) - 1 && 'YourData'[Date] < STARTOFMONTH(TODAY())),
"Present Month", CALCULATETABLE(YourData, 'YourData'[Date] >= STARTOFMONTH(TODAY()))
)
For this mesaure I got few errors which I tried to resolve but still found new errors
Error : A function 'STARTOFMONTH' has been used in a True/False expression that is used as a table filter expression. This is not allowed.
I tried one more :
CurrentDate=Today()
FilteredData =
SWITCH (
SELECTEDVALUE('SlicerTable'[DateRange]),
"Last Month", CALCULATETABLE(
FILTER(CalendarTable, 'CalendarTable'[Date] >= STARTOFMONTH(CalendarTable[CurrentDate]) - 1 && 'CalendarTable'[Date] < STARTOFMONTH(CalendarTable[CurrentDate]))
),
"Present Month", CALCULATETABLE(
FILTER(CalendarTable, 'CalendarTable'[Date] >= STARTOFMONTH(CalendarTable[CurrentDate]))
)
)
Error :The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
Even this also I tried :
StartOfMonth = STARTOFMONTH(CalendarTable[Date])
FilteredData =
SWITCH (
SELECTEDVALUE('SlicerTable'[DateRange]),
"Last Month", CALCULATETABLE(
FILTER(CalendarTable, [Date] >= [StartOfMonth] - 1 && [Date] < [StartOfMonth])
),
"Present Month", CALCULATETABLE(
FILTER(CalendarTable, [Date] >= [StartOfMonth])
)
)
Error :The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
Can u please suggest me more ...??
Thanks .
No worries, I am also in a learning phase and not as expert as others but I will try to help you as much as possible.
you have a table named 'CalendarTable' with a column 'Date' and a slicer table named 'SlicerTable' with a column 'DateRange,' you can create the following measures:
DAX
CurrentDate = TODAY()
FilteredData =
SWITCH (
SELECTEDVALUE('SlicerTable'[DateRange]),
"Last Month",
CALCULATETABLE(
YourData,
FILTER(
'CalendarTable',
'CalendarTable'[Date] >= STARTOFMONTH(TODAY()) - 1 &&
'CalendarTable'[Date] < STARTOFMONTH(TODAY())
)
),
"Present Month",
CALCULATETABLE(
YourData,
FILTER(
'CalendarTable',
'CalendarTable'[Date] >= STARTOFMONTH(TODAY())
)
)
)
Make sure to replace 'YourData' with the actual name of your main data table. This measure filters your data based on the selected value in the 'SlicerTable' slicer, considering the "Last Month" and "Present Month" options.
Note: The 'YourData' table should have a relationship with the 'CalendarTable' on the date column.
- Anonymous2 years agoNot applicable
yeah I tried this, its not working .
The error is in STARTOFMONTH() OR CALCULATETABLE() , I'm not getting. Why that STARTOFMONTH() is not accepting today() as parameter ,if we define it as varibale also it is raising same error as I mentioned above . I tried out all possible cases but still the error remains same .
- saud9682 years ago
Memorable Member
Will it be possible for you to share the PBIX file
- Anonymous2 years agoNot applicable
Nope , Sorry .
- saud9682 years ago
Memorable Member
Try following this video - https://www.youtube.com/watch?v=Su1mERlwNdM&t=233s