cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KimberlyM
Helper IV
Helper IV

CountIf using And and Or together not reporting back a different total than the total sum of item

CountIf(Lead_Data, AssignedTo.Value = AgentsName.SelectedText.Value || LeadMember1.Value = AgentsName.SelectedText.Value ||LeadMember2.Value = AgentsName.SelectedText.Value ||LeadMember3.Value = AgentsName.SelectedText.Value ||LeadMember4.Value = AgentsName.SelectedText.Value && SourceDetails.Value = "General")

 

I have lead myself to believe that this formula above says:
Count the entry if my Lead_Data source AssignedTo or,  LeadMember1 or, LeadMember2 or, LeadMember3 or, LeadMember4 column value = the name in the textbox selected AND SourceDetails must = "General".  

However I am just constantly receiving a count of the AssignedTo,  LeadMember1, LeadMember2, LeadMember3, LeadMember4 columns and it seems to be ignoring the SourceDetails column.

 

So for a particular name (CS) I would expect that the total entries under this name to be 43 and if I put the declaration of "AND SourceDetails = General" I would then expect that to report back a 0. 

Hoping this makes sense and someone can see an error I have made or show me where I am going wrong in my formula writing! Thank you in advance! 

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@KimberlyM 

A simple reordering of the FILTER might work.  I made the SourceDetails a separate criteria because it does the same thing as AND.  But the order might be what's more important here.

 

CountIf(
    Lead_Data, 
    SourceDetails.Value = "General",
    AssignedTo.Value = AgentsName.Selected.Value
    || LeadMember1.Value = AgentsName.Selected.Value
    || LeadMember2.Value = AgentsName.Selected.Value
    || LeadMember3.Value = AgentsName.Selected.Value
    || LeadMember4.Value = AgentsName.Selected.Value
)

 

 

Note: I also changed SelectedText to Selected.  SelectedText is being removed from PowerApps eventually so you will not want to use it in your app.

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

2 REPLIES 2
mdevaney
Super User
Super User

@KimberlyM 

A simple reordering of the FILTER might work.  I made the SourceDetails a separate criteria because it does the same thing as AND.  But the order might be what's more important here.

 

CountIf(
    Lead_Data, 
    SourceDetails.Value = "General",
    AssignedTo.Value = AgentsName.Selected.Value
    || LeadMember1.Value = AgentsName.Selected.Value
    || LeadMember2.Value = AgentsName.Selected.Value
    || LeadMember3.Value = AgentsName.Selected.Value
    || LeadMember4.Value = AgentsName.Selected.Value
)

 

 

Note: I also changed SelectedText to Selected.  SelectedText is being removed from PowerApps eventually so you will not want to use it in your app.

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

This worked perfectly! Thank you for suggesting this!

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 (2,810)