Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
sebastianjpue
Frequent Visitor

Default value in slicer when there is another slicer filtered

Hi guys,

I was wondering if you might help me with something that I had been struggling with for a week, so this is the case.

I have a report which contains two slicers, 1 contains the months and the other one contains the weeks from that month.

So what I want to achieve is that when the user filters for eg. April from the slicer of months, and then he wants to view the other slicer of the weeks, there is always a default value selected, in which case could be the first week of that month.

I tried to do some DAX but I had no results,

I would appreciate it if you could help me.

Thanks,
Regards,




1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @sebastianjpue ,

 

I want to acknowledge valuable input provided by @rajendraongole1 . Their initial ideas help guide my approach. However, I noticed that more details are needed to fully understand this issue.

 

(1)We create a custom visual. Get more visuals->search Preselected Slicer.

vtangjiemsft_0-1717036727905.png

(2)We can create a measure.

_FirstWeek = 
VAR _SelectedWeek = SELECTEDVALUE('DateTable'[Week])
VAR _FirstWeekOfMonth =
CALCULATE(
MIN('DateTable'[Week]),
FILTER(
ALLSELECTED(DateTable),
'DateTable'[Month] = SELECTEDVALUE('DateTable'[Month]) &&
'DateTable'[Year]= SELECTEDVALUE('DateTable'[Year])
)
)
RETURN 
 _SelectedWeek =_FirstWeekOfMonth

(3) We can create a table.

_PreselectedSlicer = DATATABLE(
    "IsDirtySlicer1", BOOLEAN, 
    {
        {FALSE()},
        {TRUE()}
       
    }
)

(4) Then the result is as follows.

vtangjiemsft_2-1717037019028.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

 

 

View solution in original post

4 REPLIES 4
v-tangjie-msft
Community Support
Community Support

Hi @sebastianjpue ,

 

I want to acknowledge valuable input provided by @rajendraongole1 . Their initial ideas help guide my approach. However, I noticed that more details are needed to fully understand this issue.

 

(1)We create a custom visual. Get more visuals->search Preselected Slicer.

vtangjiemsft_0-1717036727905.png

(2)We can create a measure.

_FirstWeek = 
VAR _SelectedWeek = SELECTEDVALUE('DateTable'[Week])
VAR _FirstWeekOfMonth =
CALCULATE(
MIN('DateTable'[Week]),
FILTER(
ALLSELECTED(DateTable),
'DateTable'[Month] = SELECTEDVALUE('DateTable'[Month]) &&
'DateTable'[Year]= SELECTEDVALUE('DateTable'[Year])
)
)
RETURN 
 _SelectedWeek =_FirstWeekOfMonth

(3) We can create a table.

_PreselectedSlicer = DATATABLE(
    "IsDirtySlicer1", BOOLEAN, 
    {
        {FALSE()},
        {TRUE()}
       
    }
)

(4) Then the result is as follows.

vtangjiemsft_2-1717037019028.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

 

 

Hi, thanks for your reply,

I did in my report the above, it almost approaches what I'm searching for. I just have 1 problem with the solution, when the week is "pre-selected", I only can view 1 month in my other slicer, the one that is currently "selected", how did you manage to see another month in your slicer in the example above, maybe I'm missing something.

Thanks in advance,

Best regards.
Sebastian

I solved it, it was the interactions, thank you so much for your solution.

Best regards,

Sebastian

rajendraongole1
Super User
Super User

Hi @sebastianjpue - Ensure your Calendar table is related to your fact table on the date key and create a measure to determine the first week of the selected month

 

FirstWeekOfMonth =
CALCULATE(
MIN(Calendar[Week]),
FILTER(
ALLSELECTED(Calendar),
Calendar[MonthNumber] = SELECTEDVALUE(Calendar[MonthNumber]) &&
Calendar[Year] = SELECTEDVALUE(Calendar[Year])
)
)

 

create another measure to select the first week condition as below:

 

IsFirstWeek =
IF(
SELECTEDVALUE(Calendar[Week]) = [FirstWeekOfMonth],
1,
0
)

Set the filter to show only when IsFirstWeek is equal to 1 for visual level filter and Add a slicer for the months using the Calendar[Month] column.
Add another slicer for the weeks using the Calendar[WeekStart] column

Try the above approach and let know

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors