cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cnorris135
Helper IV
Helper IV

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????


4 REPLIES 4
DocWHCI
Frequent Visitor

Replace the Or’s in your statement with And.

The way it is right now it will always evaluate to the lowest 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.

@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
)
SuperMarvz
Regular Visitor

Is this resolved? I'm having the same issue. I tried your code actually but not working on my end. I'm having error on the equals sign but then I tried replacing it with text. No error but the outcome I am expecting wont go. Plain grammatical error. Here's an image capture of the error:

SuperMarvz_0-1644241394823.png
PS: I only tried one condition.

 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (1,789)