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

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
Solution Sage
Solution Sage

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

Pat

View solution in original post

4 REPLIES 4
mahoneypat
Solution Sage
Solution Sage

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

Pat

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 I
Helper I

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
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (45,049)