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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
AI14
Helper III
Helper III

compare text to time

Hi

 

i need to see if my Actual is less than my target but they are in different formats. both are measures however 1 has been formatted into HH:MM so its a text and the other is a normal short time.

 

e.g.

the text time measure is as follows: Actual= Format(example),"hh:mm)  -  result is 02.45

the Target measure might say 03:55 (in short time format)

 

the if formula is not working due to formatting issues :

if(actual<target,1,0)

 

please assist

1 ACCEPTED SOLUTION

Hi @AI14 

try to use TIMEVALUE function to convert Duration to datetime data type as follows

Duration =
VAR _ref =
MAX ( a[REF] )
VAR _time1 =
MAXX ( FILTER ( ALL ( a ), a[REF] = _ref ), [ST] )
VAR _time2 =
MINX ( FILTER ( ALL ( a ), a[REF] = _ref ), [ST] )
RETURN
TIMEVALUE ( FORMAT ( _time2 - _time1, "hh:mm" ) )

View solution in original post

8 REPLIES 8
tamerj1
Super User
Super User

Hi @AI14 
You can use 
IF ( TIMEVALUE ( actual ) < target, 1, 0 )

Tried this but says i cant convert value " of type txt to type date

FreemanZ
Super User
Super User

hi @AI14 

 

try like:

Measure = 
IF(
    VALUE([Actual])< [Target], 
    1, 0 
)

 

verified with such data:

Actual = FORMAT(TIME(2,45,0), "hh:mm")

Target = TIME(1,55,0)

FreemanZ_0-1675591025733.png

 

change the target, returns 1

FreemanZ_1-1675591149534.png

 

also Tried this but says i cant convert value " of type txt to type date

hi @AI14 

can you paste your data?

the actual:

Duration =
VAR _ref = MAX(a[REF])
VAR _time1 =
MAXX(    FILTER(        ALL(a),        a[REF] = _ref    ),    [ST])
VAR _time2 =
MINX(    FILTER(        ALL(a),        a[REF] = _ref    ),    [ST])
RETURN
FORMAT(_time2 - _time1, "hh:mm")
 
AI14_0-1675616643213.png

 

the Target: (i have this as a measure and a column, both not worked)
Target = 'Task Rules'[Earliest Start]+'Task Rules'[Duration]+'Task Rules'[Endbefore]+'Task Rules'[Setup]+'Task Rules'[Cleanup]
AI14_1-1675616731708.png

 

 

 

Hi @AI14 

try to use TIMEVALUE function to convert Duration to datetime data type as follows

Duration =
VAR _ref =
MAX ( a[REF] )
VAR _time1 =
MAXX ( FILTER ( ALL ( a ), a[REF] = _ref ), [ST] )
VAR _time2 =
MINX ( FILTER ( ALL ( a ), a[REF] = _ref ), [ST] )
RETURN
TIMEVALUE ( FORMAT ( _time2 - _time1, "hh:mm" ) )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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