Forum Discussion
Power Query / M - If statement with Duration
- Anonymous5 years ago
solved this, seems the brackets used were not allowing me to complete the M code.
Solution was = if [EndTime] > [Interval End] then Duration.Seconds([EndTime] - [Interval End]) else 0
Anonymous no luck unfortunately
could you explain better what you mean by no lucky?
if you want useful help, you have to provide maximum information, otherwise it is difficult to imagine what happens
- Anonymous5 years agoNot applicable
Hi Anonymous ,
Your M below has not worked, but I believe it needs an if statement in there. I would expect something a bit more like "= if([EndTime] > [Interval End] then [Interval End]-[EndTime]else 0)" would be the answer I need?
Kind regards,
Jordan
- Anonymous5 years agoNot applicable
solved this, seems the brackets used were not allowing me to complete the M code.
Solution was = if [EndTime] > [Interval End] then Duration.Seconds([EndTime] - [Interval End]) else 0
- Anonymous5 years agoNot applicable
Hi Anonymous
you didn't explained what error my code raises.
The logic of the expression I give is the same of your if ... then .. else. Only written in a differente way.
But now I have seen an error in the sintax
this
List.Max({Duration.Seconds(#"Master Append"[Interval End]-#"Master Append"[EndTime]),0}
should be
List.Max({Duration.Seconds(#"Master Append"[Interval End]-#"Master Append"[EndTime],0})