cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Display Form Data from 1 of 2 fields (whichever has data)

Hey all!

 

I have a user option that is a Yes or No.  Based on that selection, 1 of two different items populates.  Either a dropdown where they can select to reactivate an old title, or a text field where they can type out the name of a new title.

 

The dropdown menu name is - Dropdown1

The datacard for typing would be - DataCardValue9

 

I want to populate a 3rd field based on the data in the previous fields. 

I need assistance as I am terribad with formulas, I know there would be three ways to achieve this. 

1) Either use the True or False from the selection field and based on that select the data to populate.  Ex. If False - use DataCardValue9.  If true Dropdown1.SelectedText.Value

 

2) Straight up combine both columns 'Dropdown1.SelectedText.Value' + 'Datacardvalue9?' (not sure how to combine).  With the idea that as long as there was no spaces in between only the non-blank value would appear.

3) Check if blank and display which one has data.

 

Any option that works I will utilize.  Thank you in advance!

2 ACCEPTED SOLUTIONS

Accepted Solutions
mdevaney
Super User III
Super User III

@Anonymous 

I'd do a variation of Option #1.

 

  • Create the toggle button (let's call it toggle1)
  • The user would choose yes/no from toggle1
  • Now create a text input field (lets call it text1)
  • Set the Visible property to If(toggle1.value=true,true,false)
  • Then create a dropdown field in the same position (lets call it drpdown1)
  • Set the Visible property to If(toggle1.value=false,true,false)
  • Ensure all toggle1, text1 and drpdown1 are all on the same DataCard
  • Change the DataCard property called Update to If(toggle1.value=true, text1, drpdown1.SelectedText.Value)

 

That's the general strategy right there!

 

---

Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly.  If your thought the post was helpful please give it a "Thumbs Up."

 

 

View solution in original post

Drrickryp
Super User II
Super User II

Hi @Anonymous 

One way to do it would be to use the UpdateContext() function to create a local variable.  The variable would depend on the state of your two inputs.  You would then assign the variable to the Text property of the third control.  In your case, there are three possibilities. 

The dropdown value is default and there is nothing in the textbox.  

Dropdown1.Selected.Value = "default" && !IsBlank(Textinput1.Text)

 

the Dropdown value is <> "default" and the textbox is blank

Dropdown1.Selected.Value <> "default" && IsBlank(Textinput1.Text)

The dropdown value is <> "default" and there is data in the textbox.

Dropdown1.Selected.Value <> "default" && !IsBlank(Textinput1.Text)

Putting there together in the UpdateContext() function would look like this and could be assigned to a button on the screen.

UpdateContext({option: If(Dropdown1.Selected.Value = "default" && !IsBlank(Textinput1.Text),"",
Dropdown1.Selected.Value <> "default" && IsBlank(Textinput1.Text),"Blah Blah",
Dropdown1.Selected.Value <> "default" && !IsBlank(Textinput1.Text), "Blah Blah Blah")})

Powerapps interprets If() statements for a condition that results in a true value and stops when it finds one.  You would set the Text property of the third contol to option.  In the OnVisible property of the form, you would put UpdateContext({option: ""}) so that the third control was blank to start but on using the first two controls and then pressing the button, the third control would populate with the appropriate value. 

 

View solution in original post

3 REPLIES 3
mdevaney
Super User III
Super User III

@Anonymous 

I'd do a variation of Option #1.

 

  • Create the toggle button (let's call it toggle1)
  • The user would choose yes/no from toggle1
  • Now create a text input field (lets call it text1)
  • Set the Visible property to If(toggle1.value=true,true,false)
  • Then create a dropdown field in the same position (lets call it drpdown1)
  • Set the Visible property to If(toggle1.value=false,true,false)
  • Ensure all toggle1, text1 and drpdown1 are all on the same DataCard
  • Change the DataCard property called Update to If(toggle1.value=true, text1, drpdown1.SelectedText.Value)

 

That's the general strategy right there!

 

---

Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly.  If your thought the post was helpful please give it a "Thumbs Up."

 

 

View solution in original post

Drrickryp
Super User II
Super User II

Hi @Anonymous 

One way to do it would be to use the UpdateContext() function to create a local variable.  The variable would depend on the state of your two inputs.  You would then assign the variable to the Text property of the third control.  In your case, there are three possibilities. 

The dropdown value is default and there is nothing in the textbox.  

Dropdown1.Selected.Value = "default" && !IsBlank(Textinput1.Text)

 

the Dropdown value is <> "default" and the textbox is blank

Dropdown1.Selected.Value <> "default" && IsBlank(Textinput1.Text)

The dropdown value is <> "default" and there is data in the textbox.

Dropdown1.Selected.Value <> "default" && !IsBlank(Textinput1.Text)

Putting there together in the UpdateContext() function would look like this and could be assigned to a button on the screen.

UpdateContext({option: If(Dropdown1.Selected.Value = "default" && !IsBlank(Textinput1.Text),"",
Dropdown1.Selected.Value <> "default" && IsBlank(Textinput1.Text),"Blah Blah",
Dropdown1.Selected.Value <> "default" && !IsBlank(Textinput1.Text), "Blah Blah Blah")})

Powerapps interprets If() statements for a condition that results in a true value and stops when it finds one.  You would set the Text property of the third contol to option.  In the OnVisible property of the form, you would put UpdateContext({option: ""}) so that the third control was blank to start but on using the first two controls and then pressing the button, the third control would populate with the appropriate value. 

 

View solution in original post

Anonymous
Not applicable

Testing after lunch, thumbs up now for the time you put into helping me-

 

Thank you so much!!!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,505)