Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

How to minus the Date/Time format ?

Hi All,

 

I created in table Dim Date an calculated column called GetTime. This GetTime ( formula Gettime = NOW() )  gives a current time from my PowerBI Desktop.

 

The current time is now at 13:36 and i want to make a measure that calculate the GetTime minus the roo_ID  number 1 from another table Fact WaitingRoom.

 

So the expected output when i choose/filter the roo_id number 1 is : 13:36 minus 4 minutes which result 13:32.

 

Which formula should i use to calculate this? Thanks in advances.

 

 

  • Hi Anonymous,

     

    You can try this formula in your scenario.

    ResultMeasure =
    MIN ( 'Table1'[GetTimeCol] )
        + SIGN ( MIN ( 'Table1'[Time] ) ) * TIME ( 0, ABS ( MIN ( 'Table1'[Time] ) ), 0 )

    I would suggest that we create a calculated column instead, which would be simpler.

     

    ResultCol =
    [GetTimeCol]
        + SIGN ( [Time] ) * TIME ( 0, ABS ( [Time] ), 0 )

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Best Regards!

    Dale

5 Replies

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Anonymous,

     

    Could you please mark the proper answer as solution or share the answer if it's convenient for you? That will be a help to the others.

     

    Best Regards!
    Dale

    • Anonymous's avatar
      Anonymous
      Not applicable

      vanessafvg

       

      Thanks for your response. Your formula works perfect when we have a delay of 4 minutes on some waiting room.

       

      But what if we have a early estimated time of -4 minutes?  How can i calculate this?

       

       

      • vanessafvg's avatar
        vanessafvg
        Icon for Community Champion rankCommunity Champion

        i am not sure would that be held in your rootid?

         

         

         

         

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Anonymous,

     

    You can try this formula in your scenario.

    ResultMeasure =
    MIN ( 'Table1'[GetTimeCol] )
        + SIGN ( MIN ( 'Table1'[Time] ) ) * TIME ( 0, ABS ( MIN ( 'Table1'[Time] ) ), 0 )

    I would suggest that we create a calculated column instead, which would be simpler.

     

    ResultCol =
    [GetTimeCol]
        + SIGN ( [Time] ) * TIME ( 0, ABS ( [Time] ), 0 )

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Best Regards!

    Dale