Home » DAX » Displaying a Text message when no data exist in Power BI visual

Displaying a Text message when no data exist in Power BI visual

Display Message

How you will display “Data not exist” message when data not available in Power BI chart visual? In this post I will show you how you can achieve this.

Expected output-

Custom message when data not exist

Custom message when data not exist



Let’s get started-

Sample dataset as below for this practical-

Table name – SalesData

Dataset

Dataset

Year Sale
2010 100
2011 90
2012
2013
2014
2015 700
2016 100
2017 230
2018 90
2019 100
2020 200

Before moving further let’s have a look without message how visual look like with blank data.

In dataset there is no sale for year – 2012, 2013 & 2014. In Year slicer we select Year- 2012 and you can see the card visual output, it is showing blank text.

Blank data card visual

Blank data card visual



Now we will implement some custom text message if data not available, follow these steps-

 Step-1: Load above sample dataset into Power BI and take two visuals-

  • Card visual – Drag Sale column
  • Slicer – Drag year column

Step-2: Create a measure for custom text if sales is blank, for this write below DAX code.

TotalSales_1 =
Var GetSale = SUM(SalesData[Sale])
Return
If(ISBLANK(GetSale),"No sales for this year.", GetSale)

Now drag this measure to card visual, and see the output-

Custom message in Power BI

Custom message in Power BI

Change Text message font color “Red” when no data exist-

Step-1: Create one new measure and write below DAX code-

Change color =
IF(ISBLANK(SUM(SalesData[Sale])),
"#FF0000", --Red color
"#008000"-- Green color
)

Step-2: Select card visual > go to format bar > under Data label, click on Fx icon.

Card visual conditional formatting

Card visual conditional formatting

Step-3: Color Conditional formatting dialogue box opens then select format type- Field value > then select measure in Based on field drop-down > click on OK button.

field Value conditional formatting

field Value conditional formatting

Step-4: Now select year 2012 from year slicer and see the output-

Text color message

Text color message



Implement the same for other visuals-

Step-1: Take clustered column chart into Power BI report page and drag year & sales columns into fields section.

clustered-column-chart-viz

clustered-column-chart-viz

Step-2: Create a measure for custom message, write below DAX.

TotalSales_2 =
Var GetSale = SUM(SalesData[Sale])
Return
If(ISBLANK(GetSale),"No sales for this year.", "")

This DAX is slightly different from above card visual DAX. IF sale is Blank then it will returned message else nothing.

Step-3: Now Drag one card visual top of clustered column chart and drag this measure to card visual fields section.

Turned off card visual Title, border, background & category properties.

Visual in Power BI

Visual in Power BI

Step-4: Now select card visual and go to format bar and click on Fx icon.

Step-5: Color dialogue box opens, then select format type- Field value > then select measure(change color) in Based on field drop-down > click on OK button (Ref :- see step no 2 & 3 of card visual).

Step-6: See the output-

Power BI visual

Power BI visual

Refer more DAX functions- DAX Tutorials

Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.

1 thought on “Displaying a Text message when no data exist in Power BI visual”

  1. How to display Card “Truly Blank Text Field” when (Blank) until selection is made and / or when Multi-selections have been made? “Region Name”

Leave a Reply