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

If Statemets With Galleries

I am having an issue with a gallery that i cannot figure out why.

i have 2 data sources (both SharePoint lists, both same structure just different values in the EffortMin column), Data1 & Data2.
I have a drop-down that allows you to select which data source you would like to use in the gallery.

on the Items property of the gallery i have got If( dropdown.selected.value = data1, Data1, Data2).

This issue i have is the data from one of the columns (EffortMin), the label inside the gallery has thisitem.effortmin.

When i am not running the If statement and just pointing the items at a single data source the label works fine. as soon as i add the if statement i'm getting a identifier isnt recognized when pointing to the column
All the other columns work fine like title, etc and code works when items of the gal is pointed to a single source, its only when i introduce the IF statement i get errors.

 

I have also tried this in a previous app with no issues.

1 ACCEPTED SOLUTION

Accepted Solutions
Helper I
Helper I

Update:

Ended up Creating two new data sources and solved problem.
I think the problem was with the names of the columns and me renaming them after creating the datasource.

View solution in original post

5 REPLIES 5
Advocate II
Advocate II

It sounds like your two Data sources are not identical.

Check that column names & types are identical and that the columns are in the same order.

 

As an alternative, you could try using separate gallery for each, and just hiding the one not in use?

Helper I
Helper I

They are identical

In the Galleries items i have this as a tester
//Data1
//Data2
//If( dropdown.selected.value = data1, Data1, Data2).

When i turn the comments off either of the first two rows it works fine. third row, no good.

Super User II
Super User II

@BlessedCobba 

Please post the exact items property of the dropdown, Assuming Dropdown1 has ["data1","data2"] as its items property and the datasources are Data1 and Data2 then the Items property of the gallery should be

 

If(Dropdown1.Selected.Value = "data1", Data1, Data2)

 

My guess is that without the apostrophes data1 and Data1 are ambiguous to PowerApps. You should probably change the name so that the value in the dropdown is different from the name of your lists. 

 

@Drrickryp 

I put some fake names in there as it was quicker to type out. here is the real code

Dropdown: Effort 
Items: ["SME", "Tuned"]
OnChange: If( Effort.Selected.Value = "Tuned", Set(effortBlend, "Tuned"), Set(effortBlend, "SME"))

Gallery: EffortGal 
Items: If(effortBlend = "SME", smeEffortData, tunedEffortData)
Labels 
- ThisItem.Title 
- ThisItem.Attribute
- ThisItem.EffortMin 


Of my 3 labels in the gallery, title and attribute always work, if statement or not
EffortMin only works without the if statement.

Helper I
Helper I

Update:

Ended up Creating two new data sources and solved problem.
I think the problem was with the names of the columns and me renaming them after creating the datasource.

View solution in original post

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.

Top Solution Authors
Top Kudoed Authors
Users online (66,760)