Forum Discussion

SJain's avatar
SJain
Microsoft Employee
10 years ago

Dynamic Titles

I'm working on a reporting feature using Power BI.  How can I make dynamic titles for my charts which are dependent on the filters applied only to that chart itself and should not change on selecting or filtering some option in other graphs on the page.

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    The title on a visual can't really work that way, but you might be able to fake something that looks like it. Leave title turned off for the visual and put a card visual behind it where the title should appear. Put the same visual level filters on the card as you have on the other visual and use a measure to concatenate a title using those filter criteria. The specifics from here will vary depending on exactly what you're doing. This all assumes that the filters applied only to the chart in question are not applied anywhere else on the page, and that these columns aren't going to also be further filtered by those other selections on the page.

     

    Example:

    A line chart that shows total sales for the last 90 days for product category X. The line chart has only the measure Total Sales as its value and uses DateTable[Week] on its axis. The line chart has two visual level filters:

    • DateTable[DayDiff] is greater than or equal to -90 and less than 0
    • SalesTable[Category] = "X"

     

    To give it a title generated by the filters on the chart, I created this measure:

     

    Sales90XTitle = "Total Sales Last " & 
    DISTINCTCOUNT(DateTable[Date]) & 
    " Days, Category " &
    LASTNONBLANK(SalesTable[Category], 1)

     

     

    I created a card visual and set the card to have the same two filter criteria listed above, put the card above the line chart where the title goes, and put that measure in the card. The card reads "Total Sales Last 90 Days, Category X". It ignores other selections because they are not called by the concatenation. So selecting a sales rep in another visual will further filter the line chart but the title remains the same.

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft Employee

    SJain

     

    There's no straightforward way to get a dynamic title, however a workaround with a Card visual and a measure can work.

    title = "sales for the cities "&CONCATENATEX(data,data[City],",")



     

    To make the slicer work specifically for the table, disable the interactions between the slicer and other Visuals.

    • RenuKshirsagar's avatar
      RenuKshirsagar
      Advocate II

      Hey Eric_Zhang,

             Your suggested answer works but when the Card visual is selected and the measure displaying the title is dragged, it displays  all the Slicer values even when no value is selected.

       

      Example(considering your previous post) :

                                                                            Sales for the cities London,New York,Paris

      gets displayed even when no value is selected. Is there any way to erase that off initially that could be included in the dax formula.

      So that it appears blank at first.

       

      Thanks

      • michaelswisher's avatar
        michaelswisher
        Advocate I

        Hi RenuKshirsagar,

         

        Wrap the CONCATENATEX statement with an IF statement, such as:

         

        IF(NOT(ISFILTERED(Products[Subcategory])),"All",  ....

         

        then your Concatenatex statement.  Substitute something more appropriate for "All".  You could also add another IF statement to count the number of items selected, and use a more specific description telling the user "> 6 months selected", for example.

         

        Hope this makes sense,

        Michael

  • ankitpatira's avatar
    ankitpatira
    Community Champion
    SJain in power bi desktop select slicer visual then under Formatting tab, click Edit Interactions and then you can control how other visuals behave based on slicer visual.
    • SJain's avatar
      SJain
      Microsoft Employee

      thanks ankitpatira, this did work but is it possible to attach a slicer to only a chart itself and not the whole page?