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

Filter not working with SUM

Hi,

 

I have the following code as art of an HTML text:

 

"ID: " & ContractID & " SUM: " & Sum( Filter( 'RAC Reports', ContractID = 'Contract ID'), TimeUsed)

 

'RAC Reports' is a SP list, ContractID comes from a different SP list. TimeUsed is the time per report. 

For some reason it doesn't return any values:

2021-03-01 10_53_30-Window.png

However, when I hardcode the ContractID with the number (92):

 

"ID: " & ContractID & " SUM: " & Sum( Filter( 'RAC Reports', 92 = 'Contract ID'), TimeUsed)

 

I do get the Sum() of the values:

2021-03-01 10_51_39-Window.png

I do see some errors, but don't understand what the error is in the code used:

2021-03-01 10_53_01-Window.png

 

Any idea what might be happening?

Thanks,

Bart

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@xecho 

Something is going wrong with the conversion between the two.

I would suggest using the Monitor Tool and look to see exactly what is being passed in the filter criteria.

Do you still get the error messages with the Text conversion formula, even though it returns the wrong sum?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

6 REPLIES 6
RandyHayes
Super User
Super User

@xecho 

At first glance, I'd say to change your formula to the following:

"ID: " & ContractID & " SUM: " & Sum( Filter( 'RAC Reports', Value(ContractID) = 'Contract ID'), TimeUsed)

I am not sure what type your ContractID is, but it seems to want a numeric value.

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
xecho
Helper I
Helper I

That's what I thought. On the SP list both are text values, and using Value() doesn't make any difference.

Thanks.

RandyHayes
Super User
Super User

@xecho 

If they are both text columns, then Try to convert to text instead:

"ID: " & ContractID & " SUM: " & Sum( Filter( 'RAC Reports', Text(ContractID) = 'Contract ID'), TimeUsed)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
xecho
Helper I
Helper I

That doesn't work either.

 

When I use:

"ID: " & ContractID & " SUM: " & Sum( Filter( 'RAC Reports', 'Contract ID'= Text(ContractID)), TimeUsed)

The sum will be 27390 no matter what the real sum is .

RandyHayes
Super User
Super User

@xecho 

Something is going wrong with the conversion between the two.

I would suggest using the Monitor Tool and look to see exactly what is being passed in the filter criteria.

Do you still get the error messages with the Text conversion formula, even though it returns the wrong sum?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
xecho
Helper I
Helper I

Thanks Randy,

 

I have implemented it in a different way now, not sure why the other solution was not working though.

 

Thanks again!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (4,841)