Forum Discussion

Kish1999's avatar
Kish1999
Helper II
3 years ago

Dynamic Text for a Visual

Hello All,

 

I have a requirement where I have to have a dynamic heading for a visual. The visual is a Pie chart where, the values are Department by Sales.

 

I want the visual to represent something like this " The best department is ' <Department name>' follwed by '<Dept name>'

 

Can someone please let me know how to achieve this.

 

 

Regards

3 Replies

  • Adamboer's avatar
    Adamboer
    Responsive Resident

    To achieve a dynamic heading for your Pie chart visual, you can follow these steps:

    1. Create a new measure with the following formula:

      Top 2 Departments =
      VAR DepartmentSales =
      TOPN(2,
      SUMMARIZE('Table', 'Table'[Department], "Sales", SUM('Table'[Sales])),
      [Sales], DESC)
      VAR Department1 = DepartmentSales[Department]
      VAR Department2 = DepartmentSales[Department.1]
      RETURN "The best department is '" & Department1 & "' followed by '" & Department2 & "'"

      1. Note that you will need to replace 'Table' with the name of your table and 'Sales' with the name of your sales column.

      2. Add the Pie chart visual to your report and add the Department column to the Legend field and the Sales column to the Values field.

      3. In the Visualizations pane, expand the Title card and enable the Title toggle.

      4. Click on the fx button next to the Title text box and enter the name of the measure you created in step 1.

      Now, whenever you refresh your report data, the Pie chart visual will display a dynamic heading based on the top 2 departments by sales.



  • AjayBI55's avatar
    AjayBI55
    Frequent Visitor

    Hello Kish1999 

     

    If you want to show best department as dynamic title for that you need to create one department slicer.

     

    You can use below mentioned measure you can get dynamic title.

     

    DynamicTitleCategory = var _Category = SELECTEDVALUE(Data[Product Category])
    var _finaltitle = "The best Category is " & _Category
    return
    IF(ISTEXT(_Category), _finaltitle, "Total Sales by Category")
     
     
     
     
    Did i answer you question Please mark my post📮 as solution.
     
    Thanks
    Ajay
  • Hello AjayBI55 ,

     

    Thank You for the response. But this does not solve my requirement. The requirement is,  in the second case you mentioned, the title or a text box or a card should show me the Department name whichever has the highest sales (The one 3M sales)