cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JSnapp
Frequent Visitor

Using IF statement to display different tables in a gallery.

I have a gallery that is displaying a schedule. The schedule changes each month. It references data from an excel file (temporarily). I want to be able to control which table the gallery is displaying using an IF statement in the Items menu. I cannot seem to get it to work with multiple values for the IF statement.   This is the current code, but it returns an error: If( Dropdown4_3.SelectedText.Value="July", July [, Dropdown4_3.SelectedText.Value = "August", August])

 

Is my syntax wrong or is this just not something possible inside a Gallery?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@JSnapp 

Using different datasources in an Items property is generally a bad thing to do.  It only works if the datasources have the exact same schema.  If not, then you will need to shape the data for each one in order to produce a standardized/common schema to the gallery control.

 

Also, you are using the SelectedText property which is deprecated.  You should avoid that and use just the Selected property.

 

Your formula is incorrect and should then become the following using a Switch function rather than an If:

Switch(Dropdown4_3.Selected.Value,
    "July", July,
    "August", August
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@JSnapp 

Using different datasources in an Items property is generally a bad thing to do.  It only works if the datasources have the exact same schema.  If not, then you will need to shape the data for each one in order to produce a standardized/common schema to the gallery control.

 

Also, you are using the SelectedText property which is deprecated.  You should avoid that and use just the Selected property.

 

Your formula is incorrect and should then become the following using a Switch function rather than an If:

Switch(Dropdown4_3.Selected.Value,
    "July", July,
    "August", August
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Akash17
Responsive Resident
Responsive Resident

Hi @JSnapp 

Try by using "Or" in between two conditions

If( Dropdown4_3.SelectedText.Value="July", July Or Dropdown4_3.SelectedText.Value = "August", August])

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (2,811)