Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Dear community,
I need your help with date slicers.
In my report I should have two types of date slicers:
How is it possible to automatically change "by default" values of the Date Range for the Last Month?
Thank you in advance!
Solved! Go to Solution.
Hi @Delphia
Power BI doesn't support you to set default range in slicer. You can set default range in your visual.
Here I build a sample to show you how to create visuals be imapcted by two slicers.
My Sample data is from 2021/08/01 to 2021/10/05.
I build two unrelated tables Date and Period to create slicers by Dax.
Date =
CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])) Period = {"Last Week","Overall","This Month"}
Then create a measure as below.
Filter =
VAR _LogicPeriod =
SWITCH (
SELECTEDVALUE ( Period[Value] ),
"Overall", 1,
"Last Week",
IF ( SUM ( 'Table'[Weeknum] ) = WEEKNUM ( TODAY () ) - 1, 1, 0 ),
"This Month", IF ( SUM ( 'Table'[Month] ) = MONTH ( TODAY () ), 1, 0 ),
0
)
VAR _DateRangeStart =
MIN ( 'Date'[Date] )
VAR _DateRangeEnd =
MAX ( 'Date'[Date] )
RETURN
IF (
ISFILTERED ( Period[Value] ),
SWITCH (
SELECTEDVALUE ( Period[Value] ),
"Overall", 1,
"Last Week",
IF ( SUM ( 'Table'[Weeknum] ) = WEEKNUM ( TODAY () ) - 1, 1, 0 ),
"This Month", IF ( SUM ( 'Table'[Month] ) = MONTH ( TODAY () ), 1, 0 ),
0
),
IF (
ISFILTERED ( 'Date'[Date] ),
IF (
MAX ( 'Table'[Date] ) >= _DateRangeStart
&& MAX ( 'Table'[Date] ) < _DateRangeEnd,
1,
0
),
IF ( SUM ( 'Table'[Month] ) = MONTH ( TODAY () ), 1, 0 )
)
)
Create a visual ,add this measure into Filter Field in this visual and set it to show items when value =1.
Result is as below.
By Default visual will show values in this month.
Period slicer has higher level than Date slicer. Select Last week:
Select Overall:
If Period slicer is not selected, then we can filter the visual by range in Date slicer.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Delphia
Power BI doesn't support you to set default range in slicer. You can set default range in your visual.
Here I build a sample to show you how to create visuals be imapcted by two slicers.
My Sample data is from 2021/08/01 to 2021/10/05.
I build two unrelated tables Date and Period to create slicers by Dax.
Date =
CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])) Period = {"Last Week","Overall","This Month"}
Then create a measure as below.
Filter =
VAR _LogicPeriod =
SWITCH (
SELECTEDVALUE ( Period[Value] ),
"Overall", 1,
"Last Week",
IF ( SUM ( 'Table'[Weeknum] ) = WEEKNUM ( TODAY () ) - 1, 1, 0 ),
"This Month", IF ( SUM ( 'Table'[Month] ) = MONTH ( TODAY () ), 1, 0 ),
0
)
VAR _DateRangeStart =
MIN ( 'Date'[Date] )
VAR _DateRangeEnd =
MAX ( 'Date'[Date] )
RETURN
IF (
ISFILTERED ( Period[Value] ),
SWITCH (
SELECTEDVALUE ( Period[Value] ),
"Overall", 1,
"Last Week",
IF ( SUM ( 'Table'[Weeknum] ) = WEEKNUM ( TODAY () ) - 1, 1, 0 ),
"This Month", IF ( SUM ( 'Table'[Month] ) = MONTH ( TODAY () ), 1, 0 ),
0
),
IF (
ISFILTERED ( 'Date'[Date] ),
IF (
MAX ( 'Table'[Date] ) >= _DateRangeStart
&& MAX ( 'Table'[Date] ) < _DateRangeEnd,
1,
0
),
IF ( SUM ( 'Table'[Month] ) = MONTH ( TODAY () ), 1, 0 )
)
)
Create a visual ,add this measure into Filter Field in this visual and set it to show items when value =1.
Result is as below.
By Default visual will show values in this month.
Period slicer has higher level than Date slicer. Select Last week:
Select Overall:
If Period slicer is not selected, then we can filter the visual by range in Date slicer.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Delphia , Default for range is not supported yet.
You need to have a column with that value and select that as the default
Month Type = Switch( True(),
eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
Format([Date],"MMM-YYYY")
)
refer if needed
Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=35
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 55 | |
| 35 | |
| 31 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 75 | |
| 72 | |
| 38 | |
| 35 | |
| 25 |