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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Replacing Time Stamp with a text value

Hi,

 

Newb here.

 

I have a column with time stamps in it. I want to replace the time stamp with a text value i.e if the time stamps are between 00:00:00 and equal to 11:59:59 replace with text AM. I want to do the same with PM data.

 

Please help.

 

Thanks, 

10 REPLIES 10
PattemManohar
Community Champion
Community Champion

@Anonymous  Please try this as a New Column

 

Flag = IF(HOUR([DateTime])<12,"AM","PM")

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

Thank you fpr the response. It did not work. Error: The syntax for '"AM"' is incorrect. (DAX(IF(HOUR([creation_time_utc])<12."AM","PM"))).

 

This is the formula used:

 

IF(HOUR([creation_time_utc - Copy])<12,"AM","PM")
 
Example of my column
 
Time Column.PNG

Hi @Anonymous 

 

Based on my test,the formula seems correct.Please show us the error screenshot.

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-cherch-msft ,

 

Here is a full screen print of the table. I have checked that my format settings are right on the creation time column. Am I missing something maybe format wise 

 

Time Column 2.PNG

 

 

Hi @Anonymous 

 

It is strange.Attached my sample file for your reference.If possible,please share your .pbix file.You can upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-cherch-msft 

 

Thank you for the PBI file.

 

Interesting thing I noted. When I open your PBI it shows correctly. When I go to the formula and rerun it in you pbi the same error appears.

 

I think I might miss an extension file not supporting the DAX function??

 

Will upload my PBI shortly.

Hi @Anonymous 

 

Try to re-install the power bi desktop from latest version of Power BI Desktop.

 

Regards,

Cherie

 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-cherch-msft This will be my next step. My co worker has an older version of BI and he managed to run extacly the same formula except he replaced the , with ; and it worked.

 

Will post an update after re - installation.

Anonymous
Not applicable

@v-cherch-msft 

 

I am at a complete loss. Removed Bi and reinstalled it and still no luck. 

 

Thinking of copying my co workers route folder over to see if this works.

 

Any other suggestions would be helpfull.

Hi @Anonymous 

 

Please check if this page's awareness could help you.

1.png

Regards,

Cherie 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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