cancel
Showing results for
Did you mean:
Frequent Visitor

## Problem creating a button that changes color based on two filters and one sum

Hi, I have a SP list named "Training".  This list allows employees to enter professional training taken during the year to meet the annual requirement of 20 hours.  I have a Canvas app using a gallery that allows the currently logged on employee to see the training they have taken.   I also have a button (separate from the gallery).  I would like this button to change to Green when the employee reaches 20 hours of training and remain Red if they have less than 20 hours of training.  I do not know the formula to (1) filter the training by employee (2) filter the training by year, and (3) sum the total hours by year.

List Name:  "Training".  List items:  "Email" (pulled from person/group).   "Completed" (date of training completion),  "Hours" (number entered by employee).

I've tried the following on "Fill" for the button without success:
If(Sum(Filter('Training', 'Email'.Email=User().Email, 'Completed' >= Date(2021,01,01), 'Completed' <=Date(2021,12,31), 'Hours'>= 20, Green, Red))

Thanks in advance for any help!

1 ACCEPTED SOLUTION

Accepted Solutions
Most Valuable Professional

Try some extra brackets

``````If(
Sum(
Filter(
'Training',
'Email'.Email = User().Email,
'Completed' >= Date(2021,01,01),
'Completed' <=Date(2021,12,31)
),
'Hours'
)>= 20,
Green,
Red
)
``````

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

2 REPLIES 2
Most Valuable Professional

Try some extra brackets

``````If(
Sum(
Filter(
'Training',
'Email'.Email = User().Email,
'Completed' >= Date(2021,01,01),
'Completed' <=Date(2021,12,31)
),
'Hours'
)>= 20,
Green,
Red
)
``````

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

Frequent Visitor

Thank you!  That is exactly what I needed and saved me LOTS of frustration.   Have a great day!

Announcements

#### Celebrating the May Super User of the Month: Laurens Martens

@LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!

#### Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!