Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi All,
I've got some data where i need to find the time of "00:00:00" in a column, add a day of +1 to date. Sounds simple but i keep getting errors especially with the value types.
This is what ive done below, but it keeps erroring with:
"Expression.Error: The Date value must contain the Date component.
Details:
2010-04-01T00:00:00"
What ive tried doing here is I've tried looking up all dates that contain "00:00:00" as a text type, then tried changing the results to type datetime, and then adding the +1 to the dates.
My code:
if Text.Contains([#"Reading date-time"], "00:00:00") then DateTime.FromText(Date.AddDays([#"Reading date-time"],1)) else [#"Reading date-time"])
Any help would be greaty appreciated!
Thank you
Solved! Go to Solution.
Hey nvm, i figured it out. i had the nested functions the wrong way. This works:
if Text.Contains([#"Reading date-time"], "00:00:00") then Date.AddDays(DateTime.FromText([#"Reading date-time"]),1) else [#"Reading date-time"]
Hi,
Sure heres the sample data:
Hope this helps, i cant seem to scan the column for text and THEN convert that text to a datetime so it can be outputted as a datetime. I just want to find the data in column "reading date-time" where if the field contains "00:00:00" grab it and then add a day to that field. Wonder if theres a more elegant way to approach it?
Thank you for your help so far
It's not clear what your source looks like and what you are trying to achieve.
I'm reasonably sure that the initial field is text but that means that Date.AddDays can't be used on it because that requires a date or datetime type.
Also the 2 paths from the if..then..else cannot return different datatypes. At the moment they would return text or datetime, so that won't work.
If you provide some sample data and show the desired result, we might be able to progress this.
Hey nvm, i figured it out. i had the nested functions the wrong way. This works:
if Text.Contains([#"Reading date-time"], "00:00:00") then Date.AddDays(DateTime.FromText([#"Reading date-time"]),1) else [#"Reading date-time"]
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
15 | |
13 | |
9 | |
7 | |
6 |