cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lachlanP
Frequent Visitor

How to return a string instead of (Blank)

I have a tooltip page which displays the time of an event when it is hovered over on a line chart - this works well. The field being used in the card on the tooltip is a Time Only type and has a summation method of "earliest".

Line Chart:

lachlanP_1-1627936400239.png

Tooltip page with the top card selected:

lachlanP_2-1627936516642.png


The problem is if there is no data for the day (axis value on line chart) then the tooltip displays "(Blank)". I would like to change this to the string "Not Detected". 

I have tried creating a measure:

event1Time tooltip =
var result = MIN(event1table[eventTime])
return
if(
result = BLANK(),
"Not Detected",
result
)
But it seems that the MIN() function doesnt work properly with a "Time Only" formatted column. The measure properly returns the string when it is blank, but returns "#,0.00" when there is a value, as seen above on the bottom card on the tooltip. 

I also have a column called TimeInMinutes which is an integer column representing the number of minutes from 12:00am. I use this to display the Y-axis properly on the line chart. I can use this in the measure to get the right row by using min(TimeInMinuites), but then I cant figure out how to return the corresponding eventTime column which is properly formatted for display.  

Is there a function like MIN() which works on time values? I've tried using EARLIEST() but it doesnt seem that this functions the same way as the "earliest" summation method. Or is there a different reason my MIN() function is outputting a strange value?

OR... is there a way to use my TimeInMinutes (integer) value to get the right row in the table, then return the eventTime (time only) column for that row in the same table? All I can find is the RELATED() function, but this is to reference two tables, not two columns in the same table.

Sorry for the long post - this one has me stumped though.

Thanks for the help! This community is fantastic.
1 ACCEPTED SOLUTION
Greg_Deckler
Super User IV
Super User IV

Perhaps try one of these:

event1Time tooltip =
var result = MIN(event1table[eventTime]) & ""
return
if(
result = BLANK(),
"Not Detected",
result
)

event1Time tooltip =
var result = MIN(event1table[eventTime]) & ""
return
if(
result = "#,0.00",
"Not Detected",
result
)

---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
lachlanP
Frequent Visitor

Another solution that I just found which worked, reformatting the output:

event1Time tooltip = 
var result = MIN(event1table[eventTime])

return
if(
    result = BLANK(),
    "No Data",
    FORMAT(result, "h:nn AM/PM")
    )
 
Greg_Deckler
Super User IV
Super User IV

Perhaps try one of these:

event1Time tooltip =
var result = MIN(event1table[eventTime]) & ""
return
if(
result = BLANK(),
"Not Detected",
result
)

event1Time tooltip =
var result = MIN(event1table[eventTime]) & ""
return
if(
result = "#,0.00",
"Not Detected",
result
)

---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Thanks @Greg_Deckler , the first measure worked:

event1Time tooltip =
var result = MIN(event1table[eventTime]) & ""
return
if(
result = BLANK(),
"Not Detected",
result
)


It now displays the time instead of the "#,0:00".
Could you help me understand what adding the  & ""  did to solve this? Does this force it to format result as a string?

Thanks!

@lachlanP Bingo, forces it to a string.


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Top Kudoed Authors