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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ShawnG2G2
Helper I
Helper I

Military time to standard time

I am curious if anyone knows how to solve this issue? Both columns are set to Text. 

 

Screenshot 2022-10-06 113119.png

 

2 ACCEPTED SOLUTIONS
PaulDBrown
Community Champion
Community Champion

Judging by the error message, I would say the military time column is a number type, so you need to exclude the ".." from the comparison expressions: 

ie IF('Transactions By Hour[Military Time] =  0, "12:00 AM", .....

Btw I suggest you use the SWITCH function for this:

Standard Time =
SWITCH(TRUE(), 

Transactions By Hour[Military Time] =

0, "12:00 AM",

Transactions By Hour[Military Time] < 12, Transactions By Hour[Military Time]  & ":00 AM",

Transactions By Hour[Military Time] =12, "12:00 PM",

Transactions By Hour[Military Time] > 12, Transactions By Hour[Military Time] -12 & ":00 PM")





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

@ShawnG2G2 

Actually there is a much simpler way (now that I have access to a computer instead of my phone!).

Use the following code for the calculated column:

Standard Time = 
FORMAT(TIME('Transactions By Hour'[Military Hour], 00, 00), "HH:MM AM/PM")

result.png

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

Judging by the error message, I would say the military time column is a number type, so you need to exclude the ".." from the comparison expressions: 

ie IF('Transactions By Hour[Military Time] =  0, "12:00 AM", .....

Btw I suggest you use the SWITCH function for this:

Standard Time =
SWITCH(TRUE(), 

Transactions By Hour[Military Time] =

0, "12:00 AM",

Transactions By Hour[Military Time] < 12, Transactions By Hour[Military Time]  & ":00 AM",

Transactions By Hour[Military Time] =12, "12:00 PM",

Transactions By Hour[Military Time] > 12, Transactions By Hour[Military Time] -12 & ":00 PM")





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@ShawnG2G2 

Actually there is a much simpler way (now that I have access to a computer instead of my phone!).

Use the following code for the calculated column:

Standard Time = 
FORMAT(TIME('Transactions By Hour'[Military Hour], 00, 00), "HH:MM AM/PM")

result.png

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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