Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Power Query / M - If statement with Duration

Hi all,

 

I'm looking for a bit of help converting a column built with DAX into PowerQuery. 

 

Time for next period = if('Master Append'[EndTime] > 'Master Append'[Interval End] , datediff('Master Append'[Interval End],'Master Append'[EndTime],SECOND),0) 
 
Any help would be greatly appreciated! 
 
Kind regards,
 
Jordan 
  • Anonymous's avatar
    Anonymous
    5 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

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    I don't know the DAX sintax at all, but for what I can understand, would suggest to try this:

     

    #"Time for next period" =List.Max({Duration.Seconds(#"Master Append"[Interval End]-#"Master Append"[EndTime]),0}

     

     

    If you want, as seems from picture, add a new column with this data you shoul put the left right of the expression on the tool

    add custom tool

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous no luck unfortunately  

      • Anonymous's avatar
        Anonymous
        Not applicable

        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