web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sum Filter by last 24 ...
Power Apps
Unanswered

Sum Filter by last 24 hours

(0) ShareShare
ReportReport
Posted on by 23

I am trying to sum a total by the last 24 hours.  I can't seem to get it to work. My sum work's as long as I remove the date parameter.  I have tried several different ways.

 

 

 

The timestamp field in sql is formatted as [Timestamp] [datetime2](7) NOT NULL

 

Sum(Filter('Auditing.BatchTickets',PartCode=partvar,DateTimeValue(Timestamp,ShortDateTime)>= DateAdd( Now(), -24, Hours)),Quantity)
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,456 Most Valuable Professional on at

    Hi @drobinson ,

    I am not an SQL user, but if the field is already date/time, you should be able to do this

    With(
     {
     wLast:
    	 DateAdd(
     Now(), 
     -24, 
     Hours
     )
     },
     Sum(
     Filter(
     'Auditing.BatchTickets',
     PartCode=partvar && 
     Timestamp >= wLast
     ),
     Quantity
     )
    )

    if you need to convert it, use

    DateValue(TimeStamp)

    but you should not need ShortDateTime.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

     

     

  • WarrenBelz Profile Picture
    156,456 Most Valuable Professional on at

    Hi @drobinson ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • drobinson Profile Picture
    23 on at

    did not work I get we cannot apply operator < to types datetimezone and datetime error.

  • drobinson Profile Picture
    23 on at

    Still have not found a solution.

  • WarrenBelz Profile Picture
    156,456 Most Valuable Professional on at

    I might tag @RandyHayes here - he may have an SQL solution.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @drobinson 

    I'd first recommend using a View in SQL to provide the results you want as it is a relatively static query.

     

    If that is not an option, then you will need to create a calculated column in your table to represent the date as an integer and then perform the filter on that column.  This method is mentioned in the SQL connector documentation as well.

     

    I hope this is helpful for you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard