cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
andrezhar Frequent Visitor
Frequent Visitor

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
Super User
Super User

Re: Replacing Time Stamp with a text value

@andrezhar  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 Datanaut !





andrezhar Frequent Visitor
Frequent Visitor

Re: Replacing Time Stamp with a text value

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
v-cherch-msft Super Contributor
Super Contributor

Re: Replacing Time Stamp with a text value

Hi @andrezhar 

 

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.
andrezhar Frequent Visitor
Frequent Visitor

Re: Replacing Time Stamp with a text value

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

 

 

v-cherch-msft Super Contributor
Super Contributor

Re: Replacing Time Stamp with a text value

Hi @andrezhar 

 

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.
andrezhar Frequent Visitor
Frequent Visitor

Re: Replacing Time Stamp with a text value

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.

v-cherch-msft Super Contributor
Super Contributor

Re: Replacing Time Stamp with a text value

Hi @andrezhar 

 

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.
andrezhar Frequent Visitor
Frequent Visitor

Re: Replacing Time Stamp with a text value

@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.

andrezhar Frequent Visitor
Frequent Visitor

Re: Replacing Time Stamp with a text value

@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.

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 337 members 3,027 guests
Please welcome our newest community members: