cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
alex93jansen
Helper II
Helper II

Not able to filter SQL data by date

I have a SQL dataset with the fields "activityDate" of data type 'Date' and 'activityHours' of data type 'Float'.

 

The following formula correctly retrieves the number of records for March 1, 2021

 

CountRows(
    Filter(
        '[dbo].[tmtrak_dev_records]',
        submittedBy = userEmail,
        activityDate = Date(2021, 3, 1)
    )
)

 

However, the following formula returns a blank value when retrieving the Sum of "activityHours" of records for March 1, 2021

 

Sum(
    Filter(
        '[dbo].[tmtrak_dev_records]',
        submittedBy = userEmail,
        activityDate = Date(2021, 3, 1)
    ),
    activityHours
)

 

When 'activityDate' is removed from the second Filter, the formula correctly retrieves the Sum of "activityHours" for all user records in my dataset.

 

I went through the documentation several times, but it's unclear to me why "activityDate" can be used in the first formula example, but not the second.

 

Any thoughts?

1 ACCEPTED SOLUTION

Accepted Solutions
mahoneypat
Super User
Super User

Is activityhours a numeric data type?  If not, you could wrap it in Value( ) first.

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Super User
Super User

Is activityhours a numeric data type?  If not, you could wrap it in Value( ) first.

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Thanks, this actually solved my problem! However, I do receive a Delegation warning now.

 

My database will have well over 2000 records, so this may be a new issue...

 

EDIT: activityHours has data type 'Float'

RaashiSen
Community Support
Community Support

Hello @alex93jansen ,
Thank you for confirming. If this addresses your ask, please mark mahoneypat's response as a solution.

for your delegation part, you can use variables or collections to work on this. You can get some suggestions from Forum within too.
Article to refer: Understand delegation in a canvas app - Power Apps | Microsoft Docs

alex93jansen
Helper II
Helper II

One question about delegation. The formula below throws a delegation warning due to the VALUE-function. However, will this pertain to the entire dataset size (well over 2000) or the result of FILTER (will never exceed 10)?

Sum(
    Filter(
        '[dbo].[tmtrak_dev_records]',
        submittedBy = userEmail,
        activityDate = Date(2021, 3, 1)
    ),
    VALUE(activityHours)
)

 

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,423)