Forum Discussion

Deepesh153's avatar
Deepesh153
Frequent Visitor
1 year ago
Solved

Unable to subtract two columns in the power query

I was trying to subtract two columns with date/time, time datatype on the power query but I selected the desired columns the Date , Time options on the Add Columns Section gets disabled . I don't know what is happening here if anyone can help please 

 I am on the september version 

  • In such situation, there are several useuful function.

    If you want to calculate the difference of just houre or minute part if two Date.Time use
    Duration.Minutes
    Duration.Hours
    Duration,Second


    But if you want to calculate total differnce in hours or minute use
    Duration.TotalHours
    Duration.TotalMinutes

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    The result of datetime minus datetime is a duration type value. That's why you no longer see the datetime tools. If you want the result to be 12:47:05 AM, then you need to use Duration.TotalDays (not Duration.Days) and then Time.From. So

     

    = Table.AddColumn(PriorStepOrTableName, "Time",  each Time.From(Duration.TotalDays[Subtraction])))

     

    --Nate

  • In such situation, there are several useuful function.

    If you want to calculate the difference of just houre or minute part if two Date.Time use
    Duration.Minutes
    Duration.Hours
    Duration,Second


    But if you want to calculate total differnce in hours or minute use
    Duration.TotalHours
    Duration.TotalMinutes

    • Omid_Motamedise's avatar
      Omid_Motamedise
      Icon for Super User rankSuper User

      If this answer helped resolve your issue, please consider marking it as the accepted answer. And if you found my response helpful, I'd appreciate it if you could give me kudos. Thank you!