cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cnorris135
Level: Powered On

Set Dropdown field value based on text value

ive been struggling with this one ALLLLLL DAY....

 

I have two fields in a SharePoint list called "Continuous Improvement Forms".  I created a PowerApps from this list. 

 

Original Savings (datacardvalue10) = text field

Reward Type (datacardvalue6)        = dropdown with choices (Level 1, Level 2, Level 3)

 

when then user puts in a number value in "Original Savings" e.g. 3500, it is supposed to select one of the choices in the Reward Type field.  The condition for the choices is:

>2000 and <10000     = Level 1
>10000 and <25000   = Level 2
>25000 and <100000 = Level 3

i thought i was onto something when i got one condition to work (code set on the "DefaultSelectedItems" property) 
If(Value(DataCardValue10.Text)>25000 Or Value(DataCardValue10.Text)<=100000, LookUp(Choices([@'Continuous Improvement (CI) Forms'].RewardType),Value="Level 3"))

 

this seemed to work good.  So i added in the other conditions:

If(Value(DataCardValue10.Text)>1000 Or Value(DataCardValue10.Text)<=10000, LookUp(Choices([@'Continuous Improvement (CI) Forms'].RewardType),Value="Level 1",

If(Value(DataCardValue10.Text)>10000 Or Value(DataCardValue10.Text)<=25000, LookUp(Choices([@'Continuous Improvement (CI) Forms'].RewardType),Value="Level 2",

If(Value(DataCardValue10.Text)>25000 Or Value(DataCardValue10.Text)<=100000, LookUp(Choices([@'Continuous Improvement (CI) Forms'].RewardType),Value="Level 3"))))))

 

i am running into two problems......

1.) i can NOT get the dropdown field (Reward Type) to change when  i change values in the (Original Savings).  

2.) single line fires the code.  this multiple conditions does NOT fire.

 

im at my wits end trying to get this to work.  there seems to be plenty of google info on setting text field from dropdown but not vis versa.   Why wont my code fire and what property do i need to put this on to make it change when the user changes the Original Savings field????


3 REPLIES 3
DocWHCI
Level: Powered On

Re: Set Dropdown field value based on text value

Replace the Or’s in your statement with And.

The way it is right now it will always evaluate to the lowest value
cnorris135
Level: Powered On

Re: Set Dropdown field value based on text value

yes i tried that...... and again, it doesnt work for the three lines.  it does work if i was to use just one line of code.

 

i just dont understand why this is not working.

DocWHCI
Level: Powered On

Re: Set Dropdown field value based on text value

@cnorris135 After looking closer at your if statement it looks like you have multiple nested If's. Because of this your statement is not being treated properly as an If/ElseIf/Else statement. 

 

I could be wrong but try:

 

If(
    // If
    Value(DataCardValue10.Text) > 1000 And Value(DataCardValue10.Text) <= 10000, 
        LookUp(Choices([@'Continuous Improvement (CI) Forms'].RewardType),Value="Level 1"),
    // Else If
    Value(DataCardValue10.Text) > 10000 And Value(DataCardValue10.Text) <= 25000, 
        LookUp(Choices([@'Continuous Improvement (CI) Forms'].RewardType),Value="Level 2"),
    // Else If
    Value(DataCardValue10.Text) > 25000 And Value(DataCardValue10.Text) <= 100000,
        LookUp(Choices([@'Continuous Improvement (CI) Forms'].RewardType),Value="Level 3"),
    // Else
    Blank() // do nothing
)

Helpful resources

Announcements
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

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

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