Forum Discussion
show filter datas based on slicer selection
Hello All,
I have report having data like below for last 400 days.
| Date | Sales |
| 1/1/2022 | 100 |
| 1/2/2022 | 200 |
| 1/3/2022 | 300 |
| 1/4/2022 | 34 |
| 1/5/2022 | 78 |
| 1/6/2022 | 56 |
| 1/7/2022 | 43 |
| 1/8/2022 | 45 |
| 1/9/2022 | 67 |
| 1/10/2022 | 89 |
| 1/11/2022 | 34 |
| 1/12/2022 | 56 |
| 1/13/2022 | 34 |
| 1/14/2022 | 67 |
| 1/15/2022 | 54 |
| 1/16/2022 | 67 |
| 1/17/2022 | 54 |
----------------------------------------------------------------
Now my requirement is I need to show a slicer which has 3 values.:Last 30 Days,Last 12 Weeks and Last 12 Months.
So I created that.
Now If the user select Last 30 Days ,I need to show a filter which contains last 30 days in it.
Similarly if the user selects Last 12 Weeks I need to show a filter for last 12 weeks filter (week stats from sunday)
if the user selects Last 12 MonthsI need to show a filter for last 12 Months filter.
So based on selected filter value my sales should change.
5 Replies
- amitchandak
Super User
Anonymous , Try what I show in blog
https://medium.com/chandakamit/power-bi-when-i-felt-lazy-and-i-needed-too-many-measures-ed8de20d9f79
Or create three measures and use field parameters
Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9afd
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145sRolling Days Formula: https://youtu.be/cJVj5nhkKBw
Rolling Months Formula: https://youtu.be/GS5O4G81fww
- AnonymousNot applicable
- Jihwan_Kim
Super User
Hi,
Please check the below picture and the attached pbix file.
I tried to create a sample pbix file like below.
I hope the below can provide some ideas on how to create a solution for your datamodel.
Value by slicer: = VAR _last30days = FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= TODAY () && 'Calendar'[Date] >= TODAY () - 29 ) VAR _currentweekend = MAXX ( FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = TODAY () ), 'Calendar'[End of Week] ) VAR _last12weeks = FILTER ( ALL ( 'Calendar' ), 'Calendar'[End of Week] <= _currentweekend && 'Calendar'[End of Week] >= _currentweekend - 7 * 11 ) VAR _last12months = FILTER ( ALL ( 'Calendar' ), 'Calendar'[End of Month] <= EOMONTH ( TODAY (), 0 ) && 'Calendar'[End of Month] >= EOMONTH ( TODAY (), -11 ) ) RETURN SWITCH ( SELECTEDVALUE ( Slicer[Slicer] ), "Last 30 Days", CALCULATE ( SUM ( Data[Value] ), KEEPFILTERS ( _last30days ) ), "Last 12 Weeks", CALCULATE ( SUM ( Data[Value] ), KEEPFILTERS ( _last12weeks ) ), "Last 12 Months", CALCULATE ( SUM ( Data[Value] ), KEEPFILTERS ( _last12months ) ), SUM ( Data[Value] ) )- AnonymousNot applicable
Hi Jihwan_Kim ,
Thank for your answer.
But I need to show dates as a filter for end user when I selected slicer value.
Also if they select Monthly I need to show month start dates like below.
And If they select any month i need to show the sum of sales for that month (totals days sales in month)
1/1/2022 2/1/2022 3/1/2022 4/1/2022 5/1/2022 6/1/2022 7/1/2022 8/1/2022 9/1/2022 10/1/2022 Similarly when they selected weekly I need to show last 12 weeks data.
And If they select any week i need to show that week sum of sales
9/4/2022 9/11/2022 9/18/2022 9/25/2022 10/2/2022 10/9/2022 10/16/2022 10/23/2022 10/30/2022 11/6/2022 - Jihwan_Kim
Super User
Hi,
Thank you for your feedback.
I am not sure whether I understood your question correctly, but please check the attached pbix file if it suits your requirement.
I tried to create FIELD Parameter and connect to the slicer table, like the below.
This field parameter makes Axis dynamic as per the selection of the slicer.