Forum Discussion

divya_a1's avatar
divya_a1
New Member
22 days ago

Hide/Unhide 2 visuals based on multiple slicers

###Urgent

Hi community,

I'm trying to implement a show/hide logic for a report page based on mandatory slicer selections and would appreciate some guidance.

Slicer details:
ID - Table 1
Date - Table2
Run_var - Table 3 
Run_var_value - Table 3
Description - Table 5

I have 3 table visuals. 
Visual 1 
Visual 2
Visual 3

Visual 3 has a different filter requirement than Visual 1 and Visual 2.

Run_var and Run_var_value are required only for Visual 1 and Visual 2.

Description is required only for Visual 3.

The requirement is that, the data in these visuals must appear only when all the necessary slicers are selected else it must not show any data at all. To achieve this I used the following dax and flagged the result. 

  • The DAX works correctly in a Card visual but not consistently when used as a visual-level filter on table visuals
  • The table sometimes displays data even when all mandatory slicers are not selected.
  • I need to validate both conditions:
    • Mandatory slicers have been selected.
    • The selected values form a valid combination in the data model.

 

The final requirement is to ensure that the visuals display data only when all required slicers for that specific visual have been selected; otherwise, the visual should remain completely blank.


8 Replies

  • ShahRukhSameer's avatar
    ShahRukhSameer
    Icon for Continued Contributor rankContinued Contributor

    Hi divya_a1​,

    The easiest way to make this reliable is to use a measure as a visual-level filter, rather than relying on the slicer selections directly.

    For Visual 1 and 2, you can have something like:

    Show Visual 1 =
    VAR IDSelected = ISFILTERED('Table 1'[ID])
    VAR DateSelected = ISFILTERED('Table 2'[Date])
    VAR RunVarSelected = ISFILTERED('Table 3'[Run_var])
    VAR RunVarValueSelected = ISFILTERED('Table 3'[Run_var_value])
    VAR ValidCombination =
    CALCULATE(COUNTROWS('YourFactTable'))
    RETURN
    IF(
    IDSelected &&
    DateSelected &&
    RunVarSelected &&
    RunVarValueSelected &&
    ValidCombination > 0,
    1,
    0
    )

    Then set this measure as a visual-level filter and filter it to 1.

    For Visual 3, create a separate measure which only checks ID, Date and Description.

    One thing I'd be careful with is ISFILTERED(). If your requirement is that the user must actually select a single value, HASONEVALUE() or SELECTEDVALUE() may be more appropriate.

    Also, if the important part is that the combination actually exists in the model, don't just check whether the slicers have a selection. Test the resulting filter context against the fact table, as in the COUNTROWS check above.

    That should prevent the table from showing data when the slicers are selected but the combination itself isn't valid.

  • Hi,

    You can achieve this by creating separate validation measures for Visual 1/2 and Visual 3, and then applying the appropriate measure as a visual-level filter = 1.

    The important part is to validate not only whether the mandatory slicers have selections, but also whether the selected combination actually exists in the data.

    For Visual 1 and Visual 2, you could use something like:

    Show Visual 1_2 =

    VAR HasID =

        HASONEVALUE ( 'Table 1'[ID] )

    VAR HasDate =

        HASONEVALUE ( 'Table 2'[Date] )

    VAR HasRunVar =

        HASONEVALUE ( 'Table 3'[Run_var] )

    VAR HasRunVarValue =

        HASONEVALUE ( 'Table 3'[Run_var_value] )

     

    VAR SelectedID =

        SELECTEDVALUE ( 'Table 1'[ID] )

    VAR SelectedDate =

        SELECTEDVALUE ( 'Table 2'[Date] )

    VAR SelectedRunVar =

        SELECTEDVALUE ( 'Table 3'[Run_var] )

    VAR SelectedRunVarValue =

        SELECTEDVALUE ( 'Table 3'[Run_var_value] )

     

    VAR ValidCombination =

        CALCULATE (

            COUNTROWS ( 'FactTable' ),

            TREATAS ( { SelectedID }, 'FactTable'[ID] ),

            TREATAS ( { SelectedDate }, 'FactTable'[Date] ),

            TREATAS ( { SelectedRunVar }, 'FactTable'[Run_var] ),

            TREATAS ( { SelectedRunVarValue }, 'FactTable'[Run_var_value] )

        )

     

    RETURN

        IF (

            HasID

                && HasDate

                && HasRunVar

                && HasRunVarValue

                && ValidCombination > 0,

            1,

            0

        )

    Then add Show Visual 1_2 to the Filters on this visual section of Visual 1 and Visual 2, and set it to is 1.

    For Visual 3, since Run_var and Run_var_value aren't required, create a separate measure:

    Show Visual 3 =

    VAR HasID =

        HASONEVALUE ( 'Table 1'[ID] )

    VAR HasDate =

        HASONEVALUE ( 'Table 2'[Date] )

    VAR HasDescription =

        HASONEVALUE ( 'Table 5'[Description] )

     

    VAR SelectedID =

        SELECTEDVALUE ( 'Table 1'[ID] )

    VAR SelectedDate =

        SELECTEDVALUE ( 'Table 2'[Date] )

    VAR SelectedDescription =

        SELECTEDVALUE ( 'Table 5'[Description] )

     

    VAR ValidCombination =

        CALCULATE (

            COUNTROWS ( 'FactTable' ),

            TREATAS ( { SelectedID }, 'FactTable'[ID] ),

            TREATAS ( { SelectedDate }, 'FactTable'[Date] ),

            TREATAS ( { SelectedDescription }, 'FactTable'[Description] )

        )

     

    RETURN

        IF (

            HasID

                && HasDate

                && HasDescription

                && ValidCombination > 0,

            1,

            0

        )

    Apply this measure to Visual 3 as a visual-level filter and set it to 1.

    The advantage of this approach is that it checks both conditions:

    1. All mandatory slicers have a selection.
    2. The selected values form a valid combination in the data.

    One thing to note: HASONEVALUE()/SELECTEDVALUE() assumes that the slicers are intended to be single-select. If users can select multiple values, the measure needs to be adjusted to handle multi-selection.

    Also, this approach makes the visuals return no rows, rather than physically hiding/unhiding the visual containers. If you need the visual itself to disappear from the page, then Bookmarks + Selection pane would be a better approach.

    Hope this helps.

    Thanks!

  • Hi divya_a1​ -Could you please share the current DAX measure you are using for the show/hide logic, along with the relationship/model structure between Tables and the fact table?

    relationship structure is important here because it will help determine whether the issue is related to filter propagation and whether functions such as CALCULATE, VALUES, or TREATAS fnctions.

    Once we have these above, we can better understand why the measure works correctly in a Card but behaves inconsistently when applied as a visual-level filter to the table visuals.

    Thank you

  • ShowTable_Filters =

    VAR MissingID =

    NOT ISFILTERED('Table 1'[ID])

     

    VAR MissingDate =

    NOT ISFILTERED('Table 2'[Date])

     

    VAR MissingRunVar =

    NOT ISFILTERED('Table 3'[Run_Var])

     

    VAR MissingRunVarValue =

    NOT ISFILTERED('Table 3'[Run_Var_Value])

     

    VAR MissingVersionID =

    NOT ISFILTERED('Table 3'[Version_ID])

     

    VAR MissingIterationID =

    NOT ISFILTERED('Table 3'[Iteration_ID])

     

    // VAR MissingDescription =

    // NOT ISFILTERED('Table 5'[Description])

     

    RETURN

    IF(

    MissingID

    || MissingDate

    || MissingRunVar

    || MissingRunVarValue

    || MissingIterationID

    || MissingVersionID,

    // || MissingDescription,

    1,

    0

    )


    This is the measure that I've been using now. thanks.

    • rajendraongole1's avatar
      rajendraongole1
      Icon for Super User rankSuper User

      Hi divya_a1​ -Thanks for sharing the DAX. This helps clarify the current approach.

      I can see that the you are using ISFILTERED() to determine whether each mandatory slicer has been filtered. One thing worth checking is whether ISFILTERED() is sufficient for your requirement, since it only determines whether a filter is applied to the column. Could you also share the relationship/model structure between Tabl 1, Tabl 2, Tabl 3, Tabl 5 and the fact table, particularly how the slicer columns filter the data used by Visuals 1–3? It would also be helpful to know whether the slicers allow single selection or multiple selections.

  • v-achippa's avatar
    v-achippa
    Icon for Community Support rankCommunity Support

    Hi divya_a1​,

    Thank you for reaching out to Microsoft Fabric Community.

    Thank you ShahRukhSameer​, rajendraongole1​, SamInogic​ and ryan_mayu​ ​for the prompt response.

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user's for the issue worked? Is your issue resolved?

    If not provide sample data that covers your issue or question completely, in a usable format (not as a screenshot). Do not include sensitive information or anything unrelated to the issue or question. Also, show the expected outcome based on the sample data you provided.

    Thanks and regards,
    Anjan Kumar Chippa

  • v-achippa's avatar
    v-achippa
    Icon for Community Support rankCommunity Support

    Hi divya_a1​,

    We wanted to kindly follow up to check if the solution provided by the user's for the issue worked? Is your issue resolved?

    If not provide sample data that covers your issue in a usable format and show the expected outcome based on the sample data you provided.

    Thanks and regards,
    Anjan Kumar Chippa