cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lachlanP
Helper II
Helper II

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
Super User

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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
lachlanP
Helper II
Helper II

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
Super User

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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Difinity Conference

Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.