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
atjt217
Helper III
Helper III

Label status based on Time

Hello, 

Would like to ask your help please? I have a table list of Appointment Dates and Times and I want to put a status to either Regular hours or After hours. It will be After hours if the appointment time is before 8am and on or after 5pm. Here is an example of what im trying to do: 

 

AppointmentIdDateTimeStatus
10446159/26/202112:30 PMRegular Hours
10516669/27/20215:00 PMAfter Hours
10544269/30/20213:05 PMRegular Hours
10544279/30/20213:05 AMAfter Hours
10553349/27/202110:00 AMRegular Hours
10675899/27/20218:15 AMRegular Hours
107467310/2/20219:50 AMRegular Hours
10854129/26/20211:45 PMRegular Hours
109028010/1/20217:45 AMAfter Hours
10902939/29/20212:00 PMRegular Hours
109119110/1/20212:30 PMRegular Hours
10992779/28/20215:00 PMAfter Hours
10992909/29/202110:20 AMRegular Hours
10992969/29/202110:18 AMRegular Hours

 

Please note im using direct query. I appreciate your advice. Thank you!

1 ACCEPTED SOLUTION

I found a work around on this issue and wanted to share to everyone. Instead of using TIME i extracted the Hours on the Date column using Power Query and used this calculated column formula:

Appointment Status = IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 8, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 9, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 10, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour]= 11, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour]= 12, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour]= 13, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour]= 14, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 15, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 16, "Regular Hours",

"After Hours")))))))))

View solution in original post

8 REPLIES 8
smpa01
Super User
Super User

@atjt217  not sure, but it should not yield different result for DQ

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
smpa01
Super User
Super User

@atjt217  calculated column

 

 

Column = if(TIME(08,00,00)<='Fact'[Time]&&'Fact'[Time]<=TIME(17,00,00),"reg","after")

 

 

smpa01_0-1633357991311.png

 

and in case , if this needs to be a measure

 

Measure = if(TIME(08,00,00)<=CALCULATE(MAX('Fact'[Time]))&&CALCULATE(MAX('Fact'[Time]))<=TIME(17,00,00),"reg","after")

 

smpa01_1-1633358139989.png

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hi, Thank you for responding back.

I tried both but its not working. The formula is used was: 

Status = if(TIME(08,00,00)<=vu_Bi_UnableToFill_2019ToCurrent[Time] && vu_Bi_UnableToFill_2019ToCurrent[Time]<=TIME(17,00,00),"reg","after")

 

atjt217_0-1633361214054.png

 

Is there anything i missed? Please let me know

Hi @atjt217 ,

 

Try to remove the equal sign

Column = if(TIME(08,00,00)<vu_Bi_UnableToFill_2019ToCurrent[Time] && vu_Bi_UnableToFill_2019ToCurrent[Time]<TIME(17,00,00),"reg","after")

1.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I found a work around on this issue and wanted to share to everyone. Instead of using TIME i extracted the Hours on the Date column using Power Query and used this calculated column formula:

Appointment Status = IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 8, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 9, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 10, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour]= 11, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour]= 12, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour]= 13, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour]= 14, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 15, "Regular Hours",

IF(vu_Bi_UnableToFill_2019ToCurrent[Hour] = 16, "Regular Hours",

"After Hours")))))))))

Hi @atjt217 ,

 

Glad you can find a solution, please mark your reply as an answer, more people will benefit.

 

Best Regards,

Stephen Tao

@atjt217  this is what I see. it is the same measure as previous one.

 

smpa01_0-1633361762167.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Could it has somthing to do with being in Direct query? 

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.