I have the below code working fine for filtering my gallery based on a couple comboboxes...
Filter(
EDLS,
And(
Or(
IsBlank(cmb_2_1.SelectedItems.Value),
IsEmpty(cmb_2_1.SelectedItems.Value),
Production_Name in cmb_2_1.SelectedItems.Value
),
Or(
IsBlank(cmb_2_2.SelectedItems.Ep),
IsEmpty(cmb_2_2.SelectedItems.Ep),
Episode_Number in cmb_2_2.SelectedItems.Ep
)
)
)
But I now want to add sort buttons.
I've added the below code onto 2 buttons...
//Button 1
UpdateContext({EpSort: !EpSort})
//Button 2
UpdateContext({ProdSort: !ProdSort})
I have amended the code on my Gallery to the below but it's not working and I'm a bit stumped...
SortByColumns(
Filter(
EDLS,
And(
Or(
IsBlank(cmb_2_1.SelectedItems.Value),
IsEmpty(cmb_2_1.SelectedItems.Value),
Production_Name in cmb_2_1.SelectedItems.Value
),
Or(
IsBlank(cmb_2_2.SelectedItems.Ep),
IsEmpty(cmb_2_2.SelectedItems.Ep),
Episode_Number in cmb_2_2.SelectedItems.Ep
)
),
Episode_Number If(EpSort, Descending, Ascending),
Production_Name If(ProdSort, Descending, Ascending)
)
Any help greatly appreciated.
Thanks,
Rob
Neither work unfortunately.
The first batch of code I get red x's. The second is as before, a blank gallery and a yellow warning sign.
Thanks,
Rob
Hi @RobChilds
Try this
With(
{
name: SortByColumns(
Filter(
EDLS,
And(
Or(
IsBlank(cmb_2_1.SelectedItems),
IsEmpty(cmb_2_1.SelectedItems),
Production_Name = cmb_2_1.Selected.Value
),
Or(
IsBlank(cmb_2_2.SelectedItems),
IsEmpty(cmb_2_2.SelectedItems),
Episode_Number = cmb_2_2.Selected.Ep
)
)
),
"Episode_Number", If(EpSort,SortOrder.Descending, SortOrder.Ascending),
"Production_Name", If(ProdSort,SortOrder.Descending, SortOrder.Ascending)
)
},
name
)
(Or)
With(
{
name: SortByColumns(
Filter(
EDLS,
And(
Or(
IsBlank(cmb_2_1.SelectedItems),
IsEmpty(cmb_2_1.SelectedItems),
Production_Name in cmb_2_1.Selected.Value
),
Or(
IsBlank(cmb_2_2.SelectedItems),
IsEmpty(cmb_2_2.SelectedItems),
Episode_Number in cmb_2_2.Selected.Ep
)
)
),
"Episode_Number", If(EpSort,SortOrder.Descending, SortOrder.Ascending),
"Production_Name", If(ProdSort,SortOrder.Descending, SortOrder.Ascending)
)
},
name
)
Sure thing please see attached.
I have included my combobox's code as well in case it helps.
The first combobox (cmb_2_1) uses the distinct function and is sorted alphabetically.
The second combobox (cmb_2_2) depends upon first combobox.
Many thanks,
Rob
Could you share a screenshot of your code?
Hi @RobChilds
In your original formula, there are missing commas between your sort column and sort order values. Is this is a typo in your post here? If not, resolving this may solve your problem.
Try this formula to avoid delegation warning.
With(
{
name: SortByColumns(
Filter(
EDLS,
And(
Or(
IsBlank(cmb_2_1.SelectedItems.Value),
IsEmpty(cmb_2_1.SelectedItems.Value),
Production_Name in cmb_2_1.SelectedItems.Value
),
Or(
IsBlank(cmb_2_2.SelectedItems.Ep),
IsEmpty(cmb_2_2.SelectedItems.Ep),
Episode_Number in cmb_2_2.SelectedItems.Ep
)
)
),
If(EpSort, "Episode_Number", "Production_Name") & If(EpSort, Descending, Ascending),
If(ProdSort, "Production_Name", "Episode_Number") & If(ProdSort, Descending, Ascending)
)
},
name
)
Thanks for your reply, but it doesn't immediately work. I still have a blank gallery.
The red x's have gone, replaced now with a yellow delegation warning triangle.
Also just to mention, my datasource (EDLS) is a Dataverse table in case that makes a difference.
Thanks,
Rob
Hi @RobChilds
Try this formula,
SortByColumns(
Filter(
EDLS,
And(
Or(
IsBlank(cmb_2_1.SelectedItems.Value),
IsEmpty(cmb_2_1.SelectedItems.Value),
Production_Name in cmb_2_1.SelectedItems.Value
),
Or(
IsBlank(cmb_2_2.SelectedItems.Ep),
IsEmpty(cmb_2_2.SelectedItems.Ep),
Episode_Number in cmb_2_2.SelectedItems.Ep
)
)
),
If(EpSort, "Episode_Number", "Production_Name") & If(EpSort, Descending, Ascending),
If(ProdSort, "Production_Name", "Episode_Number") & If(ProdSort, Descending, Ascending)
)
Thanks!
If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.