If and Switch are two closely related formulas. As they are fundamental to creating conditional behaviour, they are also fundamental to being successful with Power Apps. Basically, you need to learn them!
Roughly speaking you’ll use if in the following circumstances:-
- There are 2 outcomes
- The if condition is based on a number of factors such as if(ThisItem.Title = “Hello” && ThisItem.Value>10,Red,Blue)
Switch is helpful if you are just looking at 1 field but would like to do different things based on the value in the field.
In the example if the formula was placed on a button inside a gallery we could use the button to navigate to different screens. “Hello” takes us to the Hello Screen, and “World” navigates us to the World screen
Switch(ThisItem.Title, "Hello",Navigate(ScreenHello), "World",Navigate(ScreenWorld) )
In the video below I demonstrate how to use If and Switch
You can head over to the Microsoft Docs to take a detailed look by clicking below.
Good luck – and keep Power Apping!