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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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!:
The Definitive Guide to Power Query (M)

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!:
The Definitive Guide to Power Query (M)

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.