Controlling font in title of visual using dax

Hi friends can any one guide is there any dax function which make font bold or any dax function to decide color. Actually i need to have some text to be bold and some to be normal in title of a visual. I am attaching the pick what actually i need. I am able to do it with the help of text box and layer control and also by other text related visuals. I need it with dax if possible. plz suggest.

Hi @praveer82, I noticed you didn’t remove the reminder note. I edited out it for you.

Kindly make sure to include all information especially the PBIX file if necessary as providing one will help users and experts find a solution to your inquiry faster and better.

A perfect initial question includes all of the following:

  • A clear explanation of the problem you are experiencing
  • A mockup of the results you want to achieve
  • Your current work-in-progress PBIX file
  • Your underlying data file (to allow us to go into Power Query if necessary to transform your data and/or data model – often DAX questions really end up being data modeling solutions)

Check out this thread on Tools and Techniques for Providing PBIX Files with Your Forum Questions

Not completing your data may sometimes cause delay in getting an answer.

@praveer82 ,

Changing text color is easy - this can be handled via native conditional formatting and a SWITCH(TRUE()) construct. But there’s currently no way to do native conditional formatting on other text properties like bold. Thus, you’ll need a custom visual. I really like K Teams Solutions HTML CSS Viewer custom visual to handle this (interesting note: developed by @PascalKiefer , a longtime eDNA member).

I’m just beginning to scratch the surface of what this amazing visual can do, but it handles your requirement pretty easily. Here’s how I did it:

One measure for the HTML code for the Card title:

Card Title Text HTML =
"<div id=container>
Total Annual Sales
</div>"

And one measure for the CSS code to format the title, controlling color, font and font attributes (in this case bold via the font weight):

Card Title CSS = 

VAR Style1 =
"#container {
  color:#5C63A8;
  font-family: Arial;
  font-size:32px;
  font-weight:100;
  padding-top:0px;  
  position:fixed;
  width:100%;
 
  display:block;
}"

VAR Style2 =
"#container {
  color:#E61A23;
  font-family: Arial;
  font-size:32px;
  font-weight:800;
  padding-top:0px;  
  position:fixed;
  width:100%;
 
  display:block;
}"

VAR Result =
IF( [Total Sales] > 40000000,
    Style2,
    Style1
)

RETURN Result

Now just drop these two measures into the field well of the HTML-CSS visual, and you’re good to go:

I’ve put together a YouTube video on this for later this week, and we will be developing a lot more content about this visual over the course of the year.

I would also highly recommend checking out the K Team Solution’s site and downloading their sample PBIX, which illustrates all sorts of incredible things you can do with this visual.

I hope this is helpful.

  • Brian
2 Likes

Hi @praveer82
Of course, @BrianJ 's reply is absolutely correct and is a great way of doing it but let me also post an alternative solution. With the HTML Text Styler custom visual, you can create your very own KPI cards. I’ve even recorded a video that explains how this is done. Take a look at it here https://youtu.be/bdhpZkUPVvQ

Please note that the visual has just been certified by Microsoft so your KPI cards will also show up in case you export your reports to PDF or PowerPoint.

I’d be happy to show you this in a private demo session which you can schedule using this link: https://kteam.ch/text-styler-demo

2 Likes

@PascalKiefer ,

Great info - thanks! Yet another one of those cases where when I respond on the forum I end up learning as much as the original poster.

The KPI video is excellent. Lots of great options now for creating awesome KPI cards…

  • Brian
1 Like

Thanks a lot sir, regards

Thanks a ton sir, regards