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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Gresi
Frequent Visitor

Replace Time of specific Datetime

Hi at all,

 

i have a table with a column named start that represents a Datetime. Format -> 01.07.2019 05:50:00

I also have a Slicer where i can select a timespan. In this case from 6am to 2pm.

SlicerFromTo.JPG

Now when start is less than 6 i want to replace the time 05:50:00 with 06:00:00.

Start should look like 01.07.2019 06:00:00 now.

 

It would be nice if someone can help me.

 

Thanks in advance,

 

Gresi

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

 

You should first extract the time from the Datetime Value. For doing this Select the column -> Go to Modelling -> Change Datetime format (HH:MMS). This would show the Column as Time Value. Now, Create a new column with the below formula 

Once Done, Go to Modelling and change the Format back to Datetime (DD/MM/YYYY HH:MMS) as the Output Datatype from the above would be of type Text.

New_Column:= Date(Year(Date), Month(Date), Day(Date)) &IF(HOUR(Date[Time])< 6, "06:00:00",Date[Time]))

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi,

 

You should first extract the time from the Datetime Value. For doing this Select the column -> Go to Modelling -> Change Datetime format (HH:MMS). This would show the Column as Time Value. Now, Create a new column with the below formula 

Once Done, Go to Modelling and change the Format back to Datetime (DD/MM/YYYY HH:MMS) as the Output Datatype from the above would be of type Text.

New_Column:= Date(Year(Date), Month(Date), Day(Date)) &IF(HOUR(Date[Time])< 6, "06:00:00",Date[Time]))

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors