Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello
I have the following table
Current, i am unable to change the data type of the column to DateTime, as the value with Today or Yesterday are not recognised as date.
How can i replace the word Today with Today Date and yesterday with Yesterday's date.
So i can change the data type to DateTime?
Thanks
Solved! Go to Solution.
Hi @PPStar ,
You can make a little adjustment base on the reply from @mh2587 ,please find details in the attachment.
=if Text.Contains([Start time], "Today") then
DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd") & Text.AfterDelimiter([Start time], ",")
else if Text.Contains([Start time], "Yesterday") then
DateTime.ToText(DateTime.From(DateTime.LocalNow() - #duration(1, 0, 0, 0)), "yyyy-MM-dd")
& Text.AfterDelimiter([Start time], ",")
else
[Start time]
Best Regards
= if Text.Contains([YourColumnName], "Today") then DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd")
else if Text.Contains([YourColumnName], "Yesterday") then DateTime.ToText(DateTime.From(DateTime.LocalNow() - #duration(1, 0, 0, 0)), "yyyy-MM-dd")
else [YourColumnName]
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
Hello, this almost works.
The only issue is the time. I thikn using the dd/MM/yyyy HH:MM:ss shows todays date and todays time, but i need it to show the time on the table
E.g if you look at the 2nd row, it says Today, 07:00 . So the new column shows it as 20/11/2023 12:11:11, where 12:11:11 is the Hour, Minute Second NOW.
Any ideas?
Thanks
Hi @PPStar ,
You can make a little adjustment base on the reply from @mh2587 ,please find details in the attachment.
=if Text.Contains([Start time], "Today") then
DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd") & Text.AfterDelimiter([Start time], ",")
else if Text.Contains([Start time], "Yesterday") then
DateTime.ToText(DateTime.From(DateTime.LocalNow() - #duration(1, 0, 0, 0)), "yyyy-MM-dd")
& Text.AfterDelimiter([Start time], ",")
else
[Start time]
Best Regards
User | Count |
---|---|
84 | |
78 | |
70 | |
46 | |
42 |
User | Count |
---|---|
106 | |
50 | |
49 | |
40 | |
40 |