web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Adding Statement to Co...
Power Apps
Unanswered

Adding Statement to Compliance Condition Statement

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm using the following in condition to set the Default status of an PA toggle control - "Compliant", "Noncompliant".

 

There is also a need to, if possible, add the following statement.

 

The additional statement says if a Member successfully completed an approved Firefighter II coarse in the last 720 days a "Live Fire Refresher" certification is not required for "Compliance"; as the "Live Fire Refresher" requirement is met in the "Firefighter II" coarse; "Live Fire Refresher" recertification subsequently only required again every 720 days.

 

     ....If CQTitle "Firefighter II" and Difference between DteofCQ and Today is >0 "Compliant", "Noncompliant".

 

Existing Member profiles would need to show five (5) documents, at a minimum. New Member's only need to show four (4) documents for the first 720 days, at which point their initial Live Fire Refresher recertification is required and a future required for five (5) compliant documents are required.

 

3csman_0-1606925468565.png

 

Categories:
  • LRVinNC Profile Picture
    2,297 on at

    I believe what you are looking for is the DateAdd function.  
    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-dateadd-datediff

    It should look something like:  DateAdd(Today() - DteofCQ) < 720

     

    LRVinNC

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Sorry, forgot to add the existing condition language. See below. What are your thoughts on how to properly incorporate your addition? Thanks!

     

    CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) >=5 && IsBlank(LookUp(ECMmbrCQSmryGallery.AllItems, ComplianceStatus="Noncompliant"))

  • LRVinNC Profile Picture
    2,297 on at

    You didn't indicate how you determine if someone if a "NewMember" but something like this may work:

     

    If(NewMember, (DateAdd(Today() - DteofCQ) >720, Set(ComplianceStatus, "Noncompliant",  CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) <4, Set(ComplianceStatus, "Noncompliant"), CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) < 5, Set(ComplianceStatus, "Noncompliant"))

     

    In English it says 

    If this is new member, then check to see if they qualified within 720 days -- if not, set a variable  equal to non-compliant.  Otherwise, if they did qualify then check to see if they have less than 4 items listed -- if so, set a variable  equal to non-compliant. 
    Finally, if not a new member, check to see if they have less than 5 items listed -- if so, set a variable  equal to non-compliant. 

     

    Does that help?

    LRVinNC

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    We are headed in the right direction.

     

    My reference to  'New Member' was intended to give you a sense of place in the process. There is no designation, beyond the DateofCQ, that applies; specifically the DateofCQ for a CQTitle THAT STARTS WITH "Firefighter".

     

    If the Member's "Firefighter I" or "Firefighter II" certification was issued in the last 720 days it counts as the required "Live Fire Refresher", thus the Member can have only four (4) documents (the three qualification document, and either a FFI or FFII), as a new Member and be 'Compliant'.

     

    If the Member has been a Member more than 720 days a "Live Fire Refresher" certification is also REQUIRED (making the required 'count' 5).

  • LRVinNC Profile Picture
    2,297 on at

    See if this is closer:

    If((
    DateAdd(Today() - DteofCQ) >720 && CQTitle StartsWith "Firefighter" && CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) < 5, Set(ComplianceStatus, "Noncompliant", 
    DateAdd(Today() - DteofCQ) < 720 && CQTitle StartsWith "Firefighter" && CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) < 4, Set(ComplianceStatus,"Noncompliant"), Set(ComplianceStatus, "Compliant"))

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I chewed it up and spit it out. It looks like this now; something is going on with the 'date' parameters.

     

    CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) >=5 && If((DateAdd (Today() - ECMmberDteofCQFld.Text >720 && (StartsWith(ECMmbrCQTitleFld.Text, "Firefighter") && IsBlank(LookUp(ECMmbrCQSmryGallery.AllItems, ComplianceStatus="Noncompliant")) || CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) <4 && If((DateAdd (Today() - ECMmberDteofCQFld.Text <720 && (StartsWith(ECMmbrCQTitleFld.Text, "Firefighter") && IsBlank(LookUp(ECMmbrCQSmryGallery.AllItems, ComplianceStatus="Noncompliant"))

     

    3csman_1-1606950759895.png

     

     

  • LRVinNC Profile Picture
    2,297 on at

    For one thing, you can't do date math with a text field -- it has to be in date format.  Try using DateValue(ECMmberDteofCQFld.Text) to convert.  Next your parenthesis are off on the Date Add.  The format is 
    DateAdd(Value1, Value2)  when you are doing it in days (which is the default.  If you are doing something other than days you would use a 3rd paramter like DateAdd(Value1, Value, Hours).  So looking above, there is no close parentheses after your second date value  which needs to be DateAdd (Today() - ECMmberDteofCQFld.Text) > 720.  And you have too many parentheses right after the If -- you only need one If(DateAdd...  And finally, you NEED an If at the beginning (which is missing) but you don't repeat the word If.... it will only appear at the beginning of the whole thing.  The other If's are implied by the structure of your statement.

     

    It should look something more like this... there still might be some adjustments that will be needed...

    If(CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) >=5 && DateAdd (Today() - ECMmberDteofCQFld.Text) >720 && (StartsWith(ECMmbrCQTitleFld.Text, "Firefighter") && IsBlank(LookUp(ECMmbrCQSmryGallery.AllItems, ComplianceStatus="Noncompliant")) || CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) <4 && DateAdd (Today() - ECMmberDteofCQFld.Text) <720 && StartsWith(ECMmbrCQTitleFld.Text, "Firefighter") && IsBlank(LookUp(ECMmbrCQSmryGallery.AllItems, ComplianceStatus="Noncompliant"))

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Got it to this; not sure what else to fix.  Based on the content of the Gallery the condition should force the toggle to 'Active' (green). As you can see, it shows 'Inactive' (red).

     

    The error shows at the parenthesis in front of Today in both pieces of the condition; and reads "Invalid Number of Arguments: Received 1; Expected 2 - 3".

     

    Please advise.

     

    CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) >=5 && DateAdd (Today() - DateValue(ECMmberDteofCQFld.Text) <1 && StartsWith(ECMmbrCQTitleFld.Text, "Firefighter") && IsBlank(LookUp(ECMmbrCQSmryGallery.AllItems, ComplianceStatus="Noncompliant")) || CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) <=4 && DateAdd (Today() - (DateValue(ECMmberDteofCQFld.Text) <1 && StartsWith(ECMmbrCQTitleFld.Text, "Firefighter") && IsBlank(LookUp(ECMmbrCQSmryGallery.AllItems, ComplianceStatus="Noncompliant"))

     

    3csman_0-1606961200485.png

     

  • LRVinNC Profile Picture
    2,297 on at

    One observation and a couple questions...

    1.  This has to be an If statement.  You are missing the If off the front of this statement.  Look back at what I gave you.  That is part of what is causing your invalid number of arguments.

    2.  Which property of that toggle is this statement actually entered in?
    3.  What is the name of that toggle field?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hmmm, that's interesting (the IF statement). I'm currently using the following, with no IF and its working fine.

     

    CountRows(ECMmbrCQSmryGallery.AllItems.CQTitle) >=5 && IsBlank(LookUp(ECMmbrCQSmryGallery.AllItems, ComplianceStatus="Noncompliant"))

     

    Is the IF 'now' necessary because of the edits I need?

     

    The statement is in the 'Default' of the Toggle; titled 'AdminOverrideTgle'.

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard