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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Preselect value based ...
Power Apps
Unanswered

Preselect value based on another field value

(0) ShareShare
ReportReport
Posted on by 34

I would like to preselect drop down menu from DataCardValue12 to select "A" when the DataCardValue11 is equal to "Closing," otherwise leave it blank for the user to select.

 

this is what I have so far.  

OnSelect:

If(DataCardValue11.Selected.Value="Closing", "A",blank())

 

any help would be greatly appreciated.

Categories:
I have the same question (0)
  • Cat Schneider Profile Picture
    488 Most Valuable Professional on at

    Select the Combobox (DataCardValue12), and edit the Default Property:

    If(
     //To ensure the value for the record is not accidentally overwritten
     !IsBlankOrError(Parent.Default), Parent.Default,
     //To set the default selected value of the Combobox to "A" if DataCardValue equals "Closing"
     DataCardValue11.Selected.Value = "Closing", {Value: "A"}
    )

    Then edit the Reset Property:

    updtValue


    Then select the Combobox (DataCardValue11), and edit the OnChange Property:

    If(
     Self.Selected.Value = "Closing",
     UpdateContext({updtValue: true}); UpdateContext({updtValue: false})
    )

    This will then only reset the default value of DataCardValue12 if DataCardValue11 is changed to "Closing", otherwise, DataCardValue12 will remain the value it started as or that the user has selected since they began editing the record.

  • v-qiaqi@microsoft.com Profile Picture
    on at

    Hi @Poweruser811,

    Could you please tell me that how you set the Items property of the DataCardValue12?

    Are both DataCardValue12 and DataCardValue11 ComboBox or Dropdown?

     

    If they are both ComboBox, you need to set the DefaultSelectedItems property of DataCardValue12 as:

    If(DataCardValue11.Selected.Value="Closing", {Value:"A"},{})

    Here I assume that you set the DataCardValue12 Items property as Choices() function.

     

    If they are both Dropdown, you need to set the Default property:

    If(DataCardValue11.Selected.Value="Closing", "A","")

    Note that you need to set the AllowEmptySelection property of the dropdown control as true.

  • Poweruser811 Profile Picture
    34 on at

    Both fields are drop down menu.

  • Poweruser811 Profile Picture
    34 on at

    I'm having an error with the first part:

    If(
        !(Parent.Default),
        Parent.Default,
        DataCardValue11.Selected.Value = "Closing",
        {Value: "A"}
    )
     
    is this how its supposed to look?
  • Cat Schneider Profile Picture
    488 Most Valuable Professional on at

    You're missing BlankOrIsError in your formula. Try:

    If(
        !BlankOrIsError(Parent.Default),
        Parent.Default,
        DataCardValue11.Selected.Value = "Closing",
        {Value: "A"}
    )
  • Poweruser811 Profile Picture
    34 on at

    It wont take, 

    If(
        !(Parent.Default),
        Parent.Default,
        DataCardValue11.Selected.Value = "Closing",
        {Value: "A"}
    )
    Poweruser811_0-1709060858524.png

     

  • Cat Schneider Profile Picture
    488 Most Valuable Professional on at

    That is correct. You should be getting an error when you enter:

    If(
        !(Parent.Default),
        Parent.Default,
        DataCardValue11.Selected.Value = "Closing",
        {Value: "A"}
    )
     
    That is because you did not include the BlankOrIsError function that would give you the boolean value necessary for the first argument of the If function.
     
    If you want the function to work, you need to include the BlankOrIsError function between the ! and ( just like I have below:
    If(
        !BlankOrIsError(Parent.Default),
        Parent.Default,
        DataCardValue11.Selected.Value = "Closing",
        {Value: "A"}
    )
  • Poweruser811 Profile Picture
    34 on at

    That's strange, I had it in there. I tried it again and still getting an error message. 

    Poweruser811_0-1709064295997.png

    Poweruser811_1-1709064325773.png

     

  • Cat Schneider Profile Picture
    488 Most Valuable Professional on at

    What type of control is DataCardValue12? and what is the Items property value?

    If DataCardValue12 is a Dropdown control and not a Combobox control, you will need to swap out the record value and simply use "A". Meaning you would use:

    If(
        !BlankOrIsError(Parent.Default),
        Parent.Default,
        DataCardValue11.Selected.Value = "Closing",
        "A"
    )
     
    Let me know if that works or if you are still getting an error.
  • Poweruser811 Profile Picture
    34 on at

    They are both drop down menus. Do I need to set up the values first?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 840 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 332 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 275

Last 30 days Overall leaderboard