Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

If Condition on drop down selection

(1) ShareShare
ReportReport
Posted on by 289
Hello,
 
I've been provided with below logic on this forum and I've marked the Solution as Answered, So posting as a new question. And below logic is not working as expected.
If(
(GroupDropDown.Selected.Value = "Group 1" And DataCardValue4.Text <> "") Or 
(GroupDropDown.Selected.Value = "Group 2" And !IsBlank(DataCardValue15.SelectedDate)),
"Completed",
"Pending"
)
GroupDropDown is the name of the dropdown field which has 2 choices i.e. Group 1 and Group 2.
I have 3 other fields i.e. DataCardValue4 (Text Input), DataCardValue15 (Date Picker) and DataCardValue10 (Text Input)
 
Below is my requirement:
  1. When Group 1 selected from drop down and DataCardValue15 (Date Picker) is blank, show text as "Pending" in DataCardValue10 and if date is added show text as "Completed"  in DataCardValue10
  2. When Group 2 selected from drop down and DataCardValue4 is blank, show text as "Pending" in DataCardValue10 and if some text/value is added show text as "Completed" in DataCardValue10
With the above formula, when I click New Button in my form and when Group 1 is selected from the drop down, the DataCardValue10 is automatically set to "Completed" though we haven't selected date in DataCardValue15 (Date Picker).
 
Below expression is set for New Button (OnSelect Property)
ResetForm(FormInspection);NewForm(FormInspection);
Please advise, on when user clicks New Button, DataCardValue10 should always be set to "Pending".
 
Thanks!
 
  • Prem4253 Profile Picture
    Prem4253 289 on at
    If Condition on drop down selection
     
    Thanks to both.
     
    Provided expression working as expected.
  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,580 on at
    If Condition on drop down selection
    Try this - sometimes blank, empty strings and zero dates have a habit of confusing things
    If(
       (
          GroupDropDown.Selected.Value = "Group 1" And 
          Len(DataCardValue4.Text) > 0
       ) Or 
       (
          GroupDropDown.Selected.Value = "Group 2" And 
          Value(DataCardValue15.SelectedDate) > 1
       ),
       "Completed",
       "Pending"
    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Suggested answer
    Inogic Profile Picture
    Inogic 901 on at
    If Condition on drop down selection
    Hi,
     
    The issue arises because the formula logic doesn't fully align with your requirement. Additionally, when you click the New button, DataCardValue10 is being evaluated before any user input, defaulting incorrectly to "Completed."
    Fix:
    1. Set DataCardValue10 Default Property:
      Update the Default property of DataCardValue10 to dynamically check the conditions.
    If(
        GroupDropDown.Selected.Value = "Group 1",
        If(IsBlank(DataCardValue15.SelectedDate), "Pending", "Completed"),
        If(
            GroupDropDown.Selected.Value = "Group 2",
            If(IsBlank(DataCardValue4.Text), "Pending", "Completed"),
            "Pending"
        )
    )
    Explanation:
      • If Group 1 is selected and the Date Picker (DataCardValue15) is blank → "Pending".
      • If a date is selected → "Completed".
      • If Group 2 is selected and the Text Input (DataCardValue4) is blank → "Pending".
      • If text is entered → "Completed".
      • Any other case defaults to "Pending".
    1. Update the New Button (OnSelect Property):
      To ensure DataCardValue10 always resets to "Pending" on form load, modify the OnSelect of the New button:
    ResetForm(FormInspection);
    NewForm(FormInspection);
    UpdateContext({varStatus: "Pending"})
    1. Bind DataCardValue10 to the Context Variable:
      Update the Default property of DataCardValue10 to:
    varStatus
    1. Add Dynamic Updates (Optional):
      If you want DataCardValue10 to update as users interact, set the OnChange of GroupDropDown, DataCardValue4, and DataCardValue15:
    For GroupDropDown (OnChange):
    If(
        GroupDropDown.Selected.Value = "Group 1",
        UpdateContext({varStatus: If(IsBlank(DataCardValue15.SelectedDate), "Pending", "Completed")}),
        If(
            GroupDropDown.Selected.Value = "Group 2",
            UpdateContext({varStatus: If(IsBlank(DataCardValue4.Text), "Pending", "Completed")})
        )
    )
    For DataCardValue4 (OnChange):
    If(
        GroupDropDown.Selected.Value = "Group 2",
        UpdateContext({varStatus: If(IsBlank(DataCardValue4.Text), "Pending", "Completed")})
    )
    For DataCardValue15 (OnChange):
    If(
        GroupDropDown.Selected.Value = "Group 1",
        UpdateContext({varStatus: If(IsBlank(DataCardValue15.SelectedDate), "Pending", "Completed")})
    )
    Result:
    • On clicking the New button, DataCardValue10 will reset to "Pending".
    • As users select values in the dropdown, text input, or date picker, the status will correctly change to "Completed" or remain "Pending" based on the conditions
    Hope this helps.

    Thanks!

     

    Inogic Professional Services: Power Platform/Dynamics 365 CRM
    An expert technical extension for your techno-functional business needs
    Drop an email at crm@inogic.com 
    Service: https://www.inogic.com/services/ 
    Tips and Tricks: https://www.inogic.com/blog/ 

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard