Forum Discussion
User input for time and calculate duration
- Anonymous3 years ago
Hi Tevon713 ,
Here are the steps you can follow:
1. Home – Advanced Editor --Put the following code .
Generate a calendar table with HH:MM:S and copy the columns, then copy the table
let Source = List.Times(#time(0,0,0),24*60*60,#duration(0,0,0,1)), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Time"}}), #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Time", type time}}), #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Time", "Time - Copy") in #"Duplicated Column"2. Convert the columns [Time] of both tables to text, Column tools – Text.
3. Generate a slicer for the [Time] of both tables - click the ellipsis -Search - then you can enter the date on this.
4. Create measure.
Measure = var _starttimetext=SELECTEDVALUE('StartTable'[Time]) var _endtimetext=SELECTEDVALUE('EndTable'[Time]) var _start=MAXX(FILTER(ALL(StartTable),'StartTable'[Time]=_starttimetext),[Time - Copy]) var _end=MAXX(FILTER(ALL(EndTable),'EndTable'[Time]=_endtimetext),[Time - Copy]) return DATEDIFF(_start,_end,MINUTE)5. 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
Hi Tevon713 ,
Here are the steps you can follow:
1. Home – Advanced Editor --Put the following code .
Generate a calendar table with HH:MM:S and copy the columns, then copy the table
let
Source = List.Times(#time(0,0,0),24*60*60,#duration(0,0,0,1)),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Time"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Time", type time}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Time", "Time - Copy")
in
#"Duplicated Column"
2. Convert the columns [Time] of both tables to text, Column tools – Text.
3. Generate a slicer for the [Time] of both tables - click the ellipsis -Search - then you can enter the date on this.
4. Create measure.
Measure =
var _starttimetext=SELECTEDVALUE('StartTable'[Time])
var _endtimetext=SELECTEDVALUE('EndTable'[Time])
var _start=MAXX(FILTER(ALL(StartTable),'StartTable'[Time]=_starttimetext),[Time - Copy])
var _end=MAXX(FILTER(ALL(EndTable),'EndTable'[Time]=_endtimetext),[Time - Copy])
return
DATEDIFF(_start,_end,MINUTE)
5. 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
Thanks Anonymous. Not exactly what I'm seeking, but I can find way around it. Thank you again.