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

I think I need an If statement but I'm not sure how to format?

Hello everyone,

I am building out a form using a Sharepoint List. I would like to have a label that automatically states one of three options depending on what the selection on the form is. 

 

For simplicity's sake let's say my SP List contains items A-Z

 

I would like my label to generate either 1, 2, or 3 depending on which selection was made on the form. 

 

On my label, what should the text be? I tried this and it didn't work...

 

image.png

 

I feel like i'm missing something simple, so any help would be appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

The exact syntax will depend on what type of control DataCardValue14 is associated with.  I'm going to assume a dropdown since you said 'depeding on what selection is made'.  If so:

If(DataCardValue14.Selected.Value = "A", "1", 
   DataCardValue14.Selected.Value = "B", "2", 
   DataCardValue14.Selected.Value = "C", "3", 
    "0")  

You can add as many conditions as you like.  The syntax is If(control = value, what to do if true, what to do if false - which in this case is make another test.  The final zero is the false value to set if none of the rest was true.  You can add as many conditions as you need.  

In a case like this where you are testing a single value you can also use a switch which is easier to read:

Switch(DataCardValue14.Selected.Value,
      "A", "1",
      "B", "2",
      "C", "3",
      "0")
LRVinNC

------------------
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

2 REPLIES 2
Super User
Super User

The exact syntax will depend on what type of control DataCardValue14 is associated with.  I'm going to assume a dropdown since you said 'depeding on what selection is made'.  If so:

If(DataCardValue14.Selected.Value = "A", "1", 
   DataCardValue14.Selected.Value = "B", "2", 
   DataCardValue14.Selected.Value = "C", "3", 
    "0")  

You can add as many conditions as you like.  The syntax is If(control = value, what to do if true, what to do if false - which in this case is make another test.  The final zero is the false value to set if none of the rest was true.  You can add as many conditions as you need.  

In a case like this where you are testing a single value you can also use a switch which is easier to read:

Switch(DataCardValue14.Selected.Value,
      "A", "1",
      "B", "2",
      "C", "3",
      "0")
LRVinNC

------------------
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

PERFECT! 

I didn't even know switch was a thing, so thank you very much! 

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (41,590)