@Damu_007
Ah...thanks for the details. It helps a LOT! Especially now seeing that there is a third gallery in the mix.
So, you're hitting your data source a lot for all these galleries to get the same data.
I would suggest the following:
For GALLERY, set the Items property to :
GroupBy('SELHA Process Performance Questions', "Process Type", "_classifications")
Then set the Items property of Gallery_1 to:
GroupBy(Gallery1.Selected._classifications, "Process Classification", "_questions")
And your nested Gallery_2 items to:
ThisItem._questions
The above formulas will reduce the performance hits of going to the datasource so many times and will reduce the maintenance of multiple filter formulas.
Next, you don't need any hidden labels to pass things as you already have everything you need in the Galleries. You just need to reference the right things.
There is one exception to the above statement - you will need one label to be hidden that will extract values from the nested gallery. There is no purpose in that label. It is only there due to a bug/issue with how PowerApps gets values from the nested gallery. If you don't have it, it thinks the gallery is empty. If you do, it will then see the galleries. It's a whacky thing, but it resolves the issue.
Now...moving on to the end goal.
I am not seeing in your photo where you want to have this save button to save the information. I am assuming that the button would be related to the current Process Type. So, in other words, you would have a save button at the bottom or someplace that would save the question/answers for that particular Process Type selected in GALLERY.
Also not seeing in your picture where these hidden labels that you mention come into play. If those hidden labels are referencing some columns of previous filter records, then these labels will have errors with the above changes - and the ultimate goal would be to remove all of them and have your gallery contain the data that it needs.
With that assumption, your formula for that save button would be the following:
Patch('SELHA Audit Results',
Ungroup(
ForAll(Filter(Gallery_1.AllItems, !IsBlank(selhaScore.Text)) As _class,
{Answers:
ForAll(_class.Gallery_2.AllItems As _ans,
{ID: LookUp('SELHA Audit Results', 'Process Type' = GALLERY.Selected.'Process Type' &&
'Process Step' = _class.'Process Step' && Year =_ans.Year, ID),
'Question No': _ans.'Question No',
Title: _ans.Title,
Year: _ans.Year,
'Process Step': _ans.'Process Step',
'Process Classification': _class.'Process Classification',
Weight: Value(_ans.Selhaweight.Text),
Score: Value(_ans.SelhaScore.Text),
Risk: _ans.SelhaRisk.Selected.Value,
Comments: _ans.SelhaComments.Text,
'Audit Observations': _ans.SelhaAO.Text,
'PCP Update': _ans.SelhaPCPUpdate.Text
}
)
}
),
"Answers"
)
)
A lot of this formula is based on assumptions for things not seen in your picture or noted in your description, but the end result of the above is that it will create new records in the SharePoint list as needed, and update existing records as needed.
Oh...and I mentioned you need only one hidden label. That is to resolve the issue with referencing nested galleries.
So, in your Gallery_1, add a label and set the Text property to: Concat(Gallery_2.AllItems, Title)
This just creates an outer reference to an inner gallery which will then let the above patch formula see the inner gallery items properly. The label is not referenced anywhere, it just causes PowerApps to expose the nested gallery properly.
Give the above a shot and let me know if you run into issues or don't understand something.