Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
DLB13
Helper I
Helper I

Dynamic text?

Hi all - 

 

I have a bit of an atypical use for Power BI I'm trying to find a workaround for, even though I know it's not an ideal use. Basically, I need to display several sentences of text depending on what slicers (there are 5 or so) are selected. I also need to have placeholder text that displays when no slicers are selected and, ideally, when whatever slicer combo is selected does not have text that goes with it.

 

I'm using Text Enhancer by MAQ Software, which is basically just the card visual with additional text editing capabilities. How I've structured it so far is I have a spreadsheet with a project number, the card the text should be displayed on, and the text itself. I also have a separate spreadsheet the project number relates to that has metadata about the project, like year and country--these are some of the slicers. I've copied below a very basic dummy data set of how the data is organized in Excel. When making the visual in Power BI, I put the "text" as the field, and the card location as a filter. I've also put in placeholder text (project 0 in the dataset) that will display when nothing is selected, as it's the first data in the data set.

 

This somewhat works, but I have encountered a couple of issues. Thus, I'm wondering if anyone has any alternative suggestions on how to display "dynamic" text like this? I imagine this isn't the only possibility. The challenges with my approach are:

  • "First" is not always displaying the first value (I opened a separate thread about this). It works most of the time, but for some reason, it's not on a couple of the cards.
  • "0" displays if the slicer combination selected does not return an entry (in the example data set, for instance, if USA and 2020 were both selected). While in theory I could duplicate the placeholder text, it's not feasible to create placeholder text in the spreadsheet for all possible slicer combinations (with five slicers including country and year, that list is reallll long).

Looking forward to any thoughts and suggestions! Many thanks in advance!

 

Text spreadsheet:

Project NumberCard LocationText
01Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
02Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
03Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
04Amet dictum sit amet justo donec enim diam. Dapibus ultrices in iaculis nunc sed augue lacus viverra vitae. 
991 Blandit turpis cursus in hac habitasse platea.
992Vitae suscipit tellus mauris a diam maecenas. 
993Sit amet purus gravida quis blandit turpis cursus in hac. 
994Velit aliquet sagittis id consectetur purus.
1011At urna condimentum mattis pellentesque id nibh. 
1012Dis parturient montes nascetur ridiculus mus mauris. Mattis aliquam faucibus purus in massa tempor nec feugiat nisl.
1013Nec nam aliquam sem et tortor consequat id porta nibh. 
1014Vel pretium lectus quam id leo in.

 

Metadata:

Project NumberCountryYear
99USA2019
101France2020
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

The basic approach would be to write a measure like

TextToDisplay = SELECTEDVALUE ( Sheet1[Text], "Placeholder Text" )

 

This will return the text value if there is only one in the current filter context and the placeholder text otherwise. For your dataset, you'd need filters or slicers set on both Project Number and Card Location, or else the text won't be unique and the measure would return the placeholder text.

View solution in original post

3 REPLIES 3
Queryon
New Member

I built out a little Lorem Ipsum Text Generator if it's helpful.  If you need the PBIX file showing how it works, feel free to ping me.  

Ipsum = 
/* -------------------------------------------------------------------------------------------------------------------------
 Title:   Random Ipsum Lorem Text Generator.  
 Desc:    Useful for creating placeholder data without dependency on other tables or data sets. 
 Author:  Queryon // Orion Matthews. orion.matthews@queryon.com
 License: This code is free to remix/reuse. Licensed under MIT licence. https://opensource.org/licenses/MIT
 
 www.queryon.com                                                                                     Keep Calm and Queryon
 -------------------------------------------------------------------------------------------------------------------------*/

// Set the following to the same to return constant length string
var CHARACTERS_TO_RETURN_MIN = 500
var CHARACTERS_TO_RETURN_MAX = 500
var NO_SPACES = FALSE() // Useful if you are doing a random name

// standard ipsum paragraph in use since 1500s
var ipsum = "lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum"

// Duplicate the string a bit so we can pick a random spot
var ipsum2 =CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(ipsum,   ipsum), ipsum), ipsum), ipsum), ipsum), ipsum), ipsum) // this gives us a length of 3,496 to work with 

// Remove spaces if the NO_SPACES variable is set
var ipsum3 = IF(NO_SPACES=true, SUBSTITUTE(ipsum2, " ", ""), ipsum2)

// Pick out a random chunk and trim it up so their isn't spaces at the start or end. 
return trim(mid(ipsum3, RANDBETWEEN(1,500)+500, RANDBETWEEN(CHARACTERS_TO_RETURN_MIN, CHARACTERS_TO_RETURN_MAX)))

/* Bug and notes: ¯\_(ツ)_/¯
 Trim bug - Due to trimming, if MIN and MAX are set to the same it might return one or two less than exactly when spaces are allowed.
 Upper case letter bug - Can't figure out how to upper case the first letter due to random number not being declarable as a variable.  Write me if you have a solution!
 */

 

AlexisOlson
Super User
Super User

The basic approach would be to write a measure like

TextToDisplay = SELECTEDVALUE ( Sheet1[Text], "Placeholder Text" )

 

This will return the text value if there is only one in the current filter context and the placeholder text otherwise. For your dataset, you'd need filters or slicers set on both Project Number and Card Location, or else the text won't be unique and the measure would return the placeholder text.

Thank you, this is exactly what I needed!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors