Forum Discussion
Create date range using slicer's input
- 5 years ago
Hi, Anonymous
According to your description, you want to get the month period rolling sum based on the selection of Slicer of the month period and start the month, you can try my steps:
- Create two tables, one calculated table :
Date = CALENDARAUTO( )Click “Enter data” to create another table:
- Create a measure in the main table:
MONTHS ROLLING = var _selectedname=SELECTEDVALUE(Slicer[Name]) var _selecteddate=SELECTEDVALUE('Date'[Date]) var _startofmonth=DATE(YEAR(_selecteddate),MONTH(_selecteddate),1) return SWITCH( _selectedname, "3 months rolling",CALCULATE(SUM(Sales[Amount]),DATESINPERIOD('Sales'[Date],_startofmonth,-3,MONTH)), "6 months rolling",CALCULATE(SUM(Sales[Amount]),DATESINPERIOD('Sales'[Date],_startofmonth,-6,MONTH)), "12 months rolling",CALCULATE(SUM(Sales[Amount]),DATESINPERIOD('Sales'[Date],_startofmonth,-12,MONTH)), "Please select month rolling")And create two Slicers(place Slicer[Name] and Date[Date]) and a card chart, then you can get what you want, like this:
You can download my test pbix file here
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, Anonymous
According to your description, you want to get the month period rolling sum based on the selection of Slicer of the month period and start the month, you can try my steps:
- Create two tables, one calculated table :
Date = CALENDARAUTO( )
Click “Enter data” to create another table:
- Create a measure in the main table:
MONTHS ROLLING =
var _selectedname=SELECTEDVALUE(Slicer[Name])
var _selecteddate=SELECTEDVALUE('Date'[Date])
var _startofmonth=DATE(YEAR(_selecteddate),MONTH(_selecteddate),1)
return
SWITCH(
_selectedname,
"3 months rolling",CALCULATE(SUM(Sales[Amount]),DATESINPERIOD('Sales'[Date],_startofmonth,-3,MONTH)),
"6 months rolling",CALCULATE(SUM(Sales[Amount]),DATESINPERIOD('Sales'[Date],_startofmonth,-6,MONTH)),
"12 months rolling",CALCULATE(SUM(Sales[Amount]),DATESINPERIOD('Sales'[Date],_startofmonth,-12,MONTH)),
"Please select month rolling")
And create two Slicers(place Slicer[Name] and Date[Date]) and a card chart, then you can get what you want, like this:
You can download my test pbix file here
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.