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
Serdet
Post Patron
Post Patron

Time Format Boolean Column

Hi, 

 

I have created a calculated column to show if certain end time (format 09:20) is false between certain ranges.

 

DAX used

7AM-10am = IF(HOUR(dilo_master[end_time]) >= 7 && HOUR(dilo_master[end_time]) <= 10.00 ,TRUE(),FALSE())
 
I want this measure to state True if the time range is between 7:00am - 10:00am. This measure is still picking up end time values up to 10:59am.
 
Any ideas on how to cut this off at 10am?
1 ACCEPTED SOLUTION

I assumed your end time column was a Time column, but is it a DateTime?  If so, you'll have to get the time component from it like this.  You should consider splitting DateTime columns if not already.

 

7AM-10am =
VAR vTime =
    TIME ( HOUR ( dilo_master[end_time] )MINUTE ( dilo_master[end_time] )SECOND ( dilo_master[end_time] ) )
RETURN
    IF (
        vTime >= TIME ( 700 )
            && vTime <= TIME ( 1000 ),
        TRUE (),
        FALSE ()
    )

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Employee
Employee

Please try this instead

 

7AM-10am = IF(dilo_master[end_time] >= TIME(7,0,0) && dilo_master[end_time] <= TIME(10,0,0) ,TRUE(),FALSE())

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


This has returned FALSE for every row. I have tried changing my end time column format between long and short time but this has not changed the output.

 

Thanks,

 

Elliot 

I assumed your end time column was a Time column, but is it a DateTime?  If so, you'll have to get the time component from it like this.  You should consider splitting DateTime columns if not already.

 

7AM-10am =
VAR vTime =
    TIME ( HOUR ( dilo_master[end_time] )MINUTE ( dilo_master[end_time] )SECOND ( dilo_master[end_time] ) )
RETURN
    IF (
        vTime >= TIME ( 700 )
            && vTime <= TIME ( 1000 ),
        TRUE (),
        FALSE ()
    )

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thats perfect. Thank you!

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.