Forum Discussion

ronaldbalza2023's avatar
ronaldbalza2023
Icon for Continued Contributor rankContinued Contributor
4 years ago
Solved

Calculating Sales on Specific Date and Time

Hi everyone, I have a complex problem that comes to my mind, and not sure how to do it. Thanks in advance ðŸ˜Š

So I have a sales table with date&time column and its sales amount.

How can I have a measure, that sum's the number of sales starting from 6am on that day until 3am the next day?

 

Sales Table

Transaction DateSales Amount
26/05/2022 5:15am1500
26/05/2022 7:45pm300
27/05/2022 2:54am500
27/05/2022 3:00pm800
27/05/2022 5:16pm900

 

Expected Result

DateTotal Sales
25/05/20221500
26/05/2022800
27/05/20221700
  • ronaldbalza2023 , You need to create a new date column

     

    Switch(True(),

    timevalue([Transaction Date]) >= time(6,0,0), datevalue([Transaction Date]) ,

    timevalue([Transaction Date]) < time(3,0,0), datevalue([Transaction Date])-1 ,

    datevalue([Transaction Date]))

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    ronaldbalza2023 What if the transaction time between 3am to 6am.
    I think select one proper 24 hrs format

    • ronaldbalza2023's avatar
      ronaldbalza2023
      Icon for Continued Contributor rankContinued Contributor

      Hi Anonymous, it will then be added on to the next day if that makes sense. Thanks for taking the time on this. 

  • ronaldbalza2023 , You need to create a new date column

     

    Switch(True(),

    timevalue([Transaction Date]) >= time(6,0,0), datevalue([Transaction Date]) ,

    timevalue([Transaction Date]) < time(3,0,0), datevalue([Transaction Date])-1 ,

    datevalue([Transaction Date]))