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
Super User
Super User

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

@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

Super User
Super User

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

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
Super User
Super User

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

@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

Super User
Super User

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

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

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

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

 

Thank you so much!!!

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,109)