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
Kish1999
Helper II
Helper II

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 3
Adamboer
Responsive Resident
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.



Kish1999
Helper II
Helper II

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)

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")
 
AjayBI55_1-1681799889354.png
 
 
AjayBI55_0-1681799856893.png
 
Did i answer you question Please mark my post📮 as solution.
 
Thanks
Ajay

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.