Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Based on slicer selection-> graph should be hidden

I have datetable & customers dataset, both have relationship with date column
i added Year,Quater,Month,Week,Day in slicer
I have added clustered column chart in that x-axis->Year,Quater,Month,Week,Day Y-axis-> count of customers, legend->Location
when user clicks on Year then Quarter related information should be display like Q1,Q2,Q3 etc
when user clicks on Quarter then Month related information should be display like Jan,Feb,Maretc
when user clicks on Month then week related information should be display like W1,W2,W3etc
when user clicks on Week then day related information should be display like 1,2,3etc

i tired many ways output is not coming as expected by client, can anyone help me on this.it would be greatly appreciated.

many tries:
1st try:
i used four graphs and written measures to hide the graphs based on slicer sleection
when i select on year the quarter graph is fetching as per output
when i select on Q1 quarter the month graph is fetching along with Q1 data is fetchning in quarter graph same happening for other selections as well
applied visual level filters.
below is my snapshot attached.

2nd Try:
used timeline slicer and added visual level filters when i select on year in x-axis all information is coming along with quarters, months, weeks, days

  • Sergii24's avatar
    Sergii24
    1 year ago

    All kudos for the solution goes to Anonymous!

     

    Anonymous, take time to learn more about the filed parameters; it's very powerful!

    Be creative πŸ™‚ Not always the label should indicate what is happening:

    We keep the same labels but apply different logic behind them! Then, if you want, you can play around with the chart title:

     

    Chart Title = 
    VAR _SelectedParameterField = SELECTEDVALUE( Parameter[Parameter Fields] )          //get the real name of table and column used in field parameter such as: 'Table'[Quarter]
    
    //getting only word "Quarter"
    VAR _OnlyColumnNameStart = FIND("[", _SelectedParameterField )
    VAR _OnlyColumnNameEnd = FIND("]", _SelectedParameterField )
    VAR _OnlyColumnName = MID( _SelectedParameterField, _OnlyColumnNameStart +1, LEN( _SelectedParameterField ) - _OnlyColumnNameStart - 1 )          //+1 is used to get rid of "[" symbol
    //----
    
    RETURN 
        IF(
            CONTAINSSTRING( _OnlyColumnName, "_" ),
            "Sales by Week",
            "Sales by " & _OnlyColumnName
        )

     

     

    Here is the final result:

    Good luck with your project!

     

    Pbix is attached πŸ™‚

     

     

8 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Thanks for reaching out to us.

    Have you tried the field parameters?

    Here's the reference.

    Use report readers to change visuals (preview) - Power BI | Microsoft Learn

    For example, you need to create below year, quarter, month and day columns.

    Go to fields parameters, and drag them to create.

    Use the Parameter field to create the visual, then you can filter by the parameter.

     

    Best Regards,
    Stephen Tao

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous 
      if i follow the steps you suggested, when user selects year from the slicer the bar chart in  x-axis will display year data, but my requirement is not that..............
      my expected output should be like: 

      when user selects on Year then Quarter related information should be display like Q1,Q2,Q3 etc
      when user selects on Quarter then Month related information should be display like Jan,Feb,Maretc
      when user selects on Month then week related information should be display like W1,W2,W3etc
      when user selects on Week then day related information should be display like 1,2,3etc

      if i add fields to the parameters, then in slicer the text data will populate
      i need to show slicer for the user in hierarchy model like below snapshot


      if you know can you help me onthis, it would be greatly appreciated.

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

        All kudos for the solution goes to Anonymous!

         

        Anonymous, take time to learn more about the filed parameters; it's very powerful!

        Be creative πŸ™‚ Not always the label should indicate what is happening:

        We keep the same labels but apply different logic behind them! Then, if you want, you can play around with the chart title:

         

        Chart Title = 
        VAR _SelectedParameterField = SELECTEDVALUE( Parameter[Parameter Fields] )          //get the real name of table and column used in field parameter such as: 'Table'[Quarter]
        
        //getting only word "Quarter"
        VAR _OnlyColumnNameStart = FIND("[", _SelectedParameterField )
        VAR _OnlyColumnNameEnd = FIND("]", _SelectedParameterField )
        VAR _OnlyColumnName = MID( _SelectedParameterField, _OnlyColumnNameStart +1, LEN( _SelectedParameterField ) - _OnlyColumnNameStart - 1 )          //+1 is used to get rid of "[" symbol
        //----
        
        RETURN 
            IF(
                CONTAINSSTRING( _OnlyColumnName, "_" ),
                "Sales by Week",
                "Sales by " & _OnlyColumnName
            )

         

         

        Here is the final result:

        Good luck with your project!

         

        Pbix is attached πŸ™‚

         

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Sergii24 , Anonymous 

    Thank you so much for your insightful suggestion regarding field parameters. I truly appreciate the guidance.

    I have a follow-up question regarding a specific requirement:
    In my current report, we used field parameters to dynamically switch between Year, Quarter, Month, Week, and Day views. While this works well, I have a large dataset, and I’d like to provide users with a more intuitive way to select specific data. Specifically, I’m looking to implement a slicer which i rounded off with blue in snapshot (instead of the parameter dropdown) that allows users to interact with and filter data efficiently.

    Is there a recommended approach to achieve this using field parameters or a similar method?



     

    Once again, thank you for your support and guidance! Looking forward to hearing your thoughts.


     

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

      Hi Anonymous, create a filed parameter -> place two slicers with it on a canvas -> select the second slicer ->right click on field name in "Field section" ->"Show values of selected field".

       

      This will bring you from this:

       

      To this:

      Good luck! πŸ™‚

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Sergii24

        First, I want to express my sincere thanks for your support so farβ€”it's been incredibly helpful.

        I followed the steps we discussed to set up the dynamic graph display in Power BI.
        However, I’m encountering an issue:

        • When I select Q1 in the slicer, the graph is showing Q1, but it should display the corresponding month-related information (e.g., Jan, Feb, Mar).
        • Similarly, when I select Jan, the graph is fetching Q1, which indicates that the parent-level filters are being applied instead of showing the expected data for the selected level.

        Could you please help me address this issue? I’d really appreciate your guidance to resolve this behavior.

        • When the user selects Quarter, the graph correctly displays the corresponding Month information, which meets my requirement.
        • Similarly, when selecting Year, it displays Quarter, and for Month, it displays Week, and for Week, it displays Day.

        While this behavior works perfectly with individual slicers for each level, my requirement is to use a hierarchical slicer instead. Based on the level selected in the hierarchy (Year, Quarter, Month, Week, or Day), the output should dynamically populate the related data at the next level.