Forum Discussion
Grouping Time by Hour Intervals
- Anonymous5 years ago
Hi atjt217 ,
Here are the steps you can follow:
1. Create calculated column.
C_CreateIOn = var _1=FORMAT('Table'[CreateIOn],"AM/PM") var _2= IF( 'Table'[CreateIOn Hour]>12, 'Table'[CreateIOn Hour]-12, 'Table'[CreateIOn Hour]) return _2&""&_12. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Anonymous5 years ago
Hi atjt217 ,
Here are the steps you can follow:
1. Create calculated column.
C_CreateIOn = SWITCH( TRUE(), 'Table'[CreateIOn Hour]>12,'Table'[CreateIOn Hour]-12&""&"PM", 'Table'[CreateIOn Hour]=12,'Table'[CreateIOn Hour]&""&"PM", 'Table'[CreateIOn Hour]<12,'Table'[CreateIOn Hour]&""&"AM")2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
atjt217 You can do all of it in Power Query, here's one example that should work:
let
StartDate = #datetime(2020,7,1,0,0,0),
EndDate = #datetime(2030,12,31,0,0,0),
DateTime = List.DateTimes(StartDate, Duration.Days(EndDate-StartDate), #duration(0,1,0,0)),
#"Converted to Table" = Table.FromList(DateTime, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "DateTime"}}),
#"Inserted Time" = Table.AddColumn(#"Renamed Columns", "Time", each DateTime.Time([DateTime]), type time),
#"Inserted Text Before Delimiter" = Table.AddColumn(#"Inserted Time", "Hour", each Text.BeforeDelimiter(Text.From([Time], "en-US"), ":"), type text),
#"Inserted Last Characters" = Table.AddColumn(#"Inserted Text Before Delimiter", "Last Characters", each Text.End(Text.From([Time], "en-US"), 2), type text)
in
#"Inserted Last Characters"
- atjt2175 years agoHelper III
Hello Allison,
I tried this out but it switches my table to Import mode and i need this to still be a direct query. Do you have any other options for me?