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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Lierreyy
Helper I
Helper I

Filter that user can modify except default criteria that can't be removed

Hi there,

I have a report where I have a default filter for a field and the user should be able to change the filter, but the default filter criteria can’t be removed. In essence the user should be able to add to the filter criteria, but not be able to remove the default filter criteria. Below are more details with some sample data that explains further.

I have two tables like the following:

 

Bill Cycle:

Bill IDWindow Start DateBill Cycle to UseBill Cycle Days Passed
15/9/2022FALSE11
25/10/2022FALSE10
35/11/2022FALSE9
45/12/2022FALSE8
55/13/2022TRUE7
65/16/2022FALSE4
75/17/2022FALSE3

 

There are a couple of calculated columns in this table as follows:

 

Bill Cycle Days Passed = TODAY() - 'Bill Cycle'[Window Start Date]
Bill Cycle to Use = IF(TODAY()-7 = 'Bill Cycle'[Window Start Date], TRUE(), FALSE())

 

Accounts:

Account IDBill IDFirst NameLast Name
11Sample First Name 1Sample Last Name 1
21Sample First Name 2Sample Last Name 2
31Sample First Name 3Sample Last Name 3
42Sample First Name 4Sample Last Name 4
52Sample First Name 5Sample Last Name 5
62Sample First Name 6Sample Last Name 6
73Sample First Name 7Sample Last Name 7
83Sample First Name 8Sample Last Name 8
93Sample First Name 9Sample Last Name 9
104Sample First Name 10Sample Last Name 10
114Sample First Name 11Sample Last Name 11
124Sample First Name 12Sample Last Name 12
135Sample First Name 13Sample Last Name 13
145Sample First Name 14Sample Last Name 14
155Sample First Name 15Sample Last Name 15
166Sample First Name 16Sample Last Name 16
176Sample First Name 17Sample Last Name 17
186Sample First Name 18Sample Last Name 18
197Sample First Name 19Sample Last Name 19
207Sample First Name 20Sample Last Name 20
217Sample First Name 21Sample Last Name 21

 

These two tables are related to eachother with the Bill ID.

I need to make a table visual that will show all the accounts for the 7th day (Bill Cycle Days Passed = 7). I have no issues doing this by either using a slicer or using the filter pane.

But my issue is that I also need the user to be able to select other days (e.g. if the user wants to select the 8th day, they should be able to). However, the user should never be able to remove the 7th day.

How do I make a filter that allows a user to modify, but one specific criteria (the 7th day always filtered) can’t be changed?

Thanks!

 

2 ACCEPTED SOLUTIONS
DataInsights
Super User
Super User

@Lierreyy,

 

This solution uses a clone of the Accounts table with no relationships. Filtering is achieved via DAX instead of a relationship.

 

Create calculated table:

 

Accounts Visual = Accounts

 

Create measure:

 

Accounts to Display = 
VAR vFilter =
    FILTER (
        'Accounts Visual',
        'Accounts Visual'[Bill ID]
            IN VALUES ( 'Bill Cycle'[Bill ID] )
                || 'Accounts Visual'[Bill ID]
                    IN CALCULATETABLE (
                        VALUES ( 'Bill Cycle'[Bill ID] ),
                        'Bill Cycle'[Bill Cycle Days Passed] = 7
                    )
    )
VAR vResultWithSlicerSelection =
    CALCULATE ( COUNT ( 'Accounts Visual'[Account ID] ), vFilter )
VAR vResultWithNoSlicerSelection =
    CALCULATE (
        COUNT ( 'Accounts Visual'[Account ID] ),
        'Accounts Visual'[Bill ID]
            IN CALCULATETABLE (
                VALUES ( 'Bill Cycle'[Bill ID] ),
                'Bill Cycle'[Bill Cycle Days Passed] = 7
            )
    )
VAR vResult =
    IF (
        ISFILTERED ( 'Bill Cycle' ),
        vResultWithSlicerSelection,
        vResultWithNoSlicerSelection
    )
RETURN
    vResult

 

Create a table visual using fields from the Accounts Visual table, and create a visual filter using the measure above:

 

DataInsights_0-1653230785989.png

 

DataInsights_1-1653230831157.png

------------------------------

 

DataInsights_2-1653230867793.png

 





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

Proud to be a Super User!




View solution in original post

v-easonf-msft
Community Support
Community Support

Hi, @Lierreyy 

Borrowing from @DataInsights ‘s solution, I made some changes.

Please try the following steps:
1. Add a seperated table as below:

Slicer = DISTINCT('Bill Cycle'[Bill Cycle Days Passed])

 2. Add a measure as below and apply it to the visual filter pane

visual filter = 
VAR _selected =
    IF (
        MAX ( 'Bill Cycle'[Bill Cycle Days Passed] )
            IN VALUES ( 'Slicer'[Bill Cycle Days Passed] )
                || MAX ( 'Bill Cycle'[Bill Cycle Days Passed] ) = 7,
        1,
        0
    )
VAR _unselected =
    IF ( MAX ( 'Bill Cycle'[Bill Cycle Days Passed] ) = 7, 1, 0 )
RETURN
    IF ( ISFILTERED ( 'Slicer'[Bill Cycle Days Passed] ), _selected, _unselected )

veasonfmsft_1-1653361308748.png

 

veasonfmsft_0-1653361275935.png

Best Regards,
Community Support Team _ Eason

 

 

View solution in original post

3 REPLIES 3
Lierreyy
Helper I
Helper I

Thank you @DataInsights & @v-easonf-msft!! These are great solutions and does exactly what I'm trying to do! Thank you both!

v-easonf-msft
Community Support
Community Support

Hi, @Lierreyy 

Borrowing from @DataInsights ‘s solution, I made some changes.

Please try the following steps:
1. Add a seperated table as below:

Slicer = DISTINCT('Bill Cycle'[Bill Cycle Days Passed])

 2. Add a measure as below and apply it to the visual filter pane

visual filter = 
VAR _selected =
    IF (
        MAX ( 'Bill Cycle'[Bill Cycle Days Passed] )
            IN VALUES ( 'Slicer'[Bill Cycle Days Passed] )
                || MAX ( 'Bill Cycle'[Bill Cycle Days Passed] ) = 7,
        1,
        0
    )
VAR _unselected =
    IF ( MAX ( 'Bill Cycle'[Bill Cycle Days Passed] ) = 7, 1, 0 )
RETURN
    IF ( ISFILTERED ( 'Slicer'[Bill Cycle Days Passed] ), _selected, _unselected )

veasonfmsft_1-1653361308748.png

 

veasonfmsft_0-1653361275935.png

Best Regards,
Community Support Team _ Eason

 

 

DataInsights
Super User
Super User

@Lierreyy,

 

This solution uses a clone of the Accounts table with no relationships. Filtering is achieved via DAX instead of a relationship.

 

Create calculated table:

 

Accounts Visual = Accounts

 

Create measure:

 

Accounts to Display = 
VAR vFilter =
    FILTER (
        'Accounts Visual',
        'Accounts Visual'[Bill ID]
            IN VALUES ( 'Bill Cycle'[Bill ID] )
                || 'Accounts Visual'[Bill ID]
                    IN CALCULATETABLE (
                        VALUES ( 'Bill Cycle'[Bill ID] ),
                        'Bill Cycle'[Bill Cycle Days Passed] = 7
                    )
    )
VAR vResultWithSlicerSelection =
    CALCULATE ( COUNT ( 'Accounts Visual'[Account ID] ), vFilter )
VAR vResultWithNoSlicerSelection =
    CALCULATE (
        COUNT ( 'Accounts Visual'[Account ID] ),
        'Accounts Visual'[Bill ID]
            IN CALCULATETABLE (
                VALUES ( 'Bill Cycle'[Bill ID] ),
                'Bill Cycle'[Bill Cycle Days Passed] = 7
            )
    )
VAR vResult =
    IF (
        ISFILTERED ( 'Bill Cycle' ),
        vResultWithSlicerSelection,
        vResultWithNoSlicerSelection
    )
RETURN
    vResult

 

Create a table visual using fields from the Accounts Visual table, and create a visual filter using the measure above:

 

DataInsights_0-1653230785989.png

 

DataInsights_1-1653230831157.png

------------------------------

 

DataInsights_2-1653230867793.png

 





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

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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