Hello everyone,
I'm trying to filter a sharepoint source into a collection based on items in a gallery. So for example, my gallery has the following items - "Facility, Horticulture..." then I have a collection that I need to filter to show items that have facility or horticulture as the unit or whatever items that are in the gallery. My problem is, I don't know how to do it. I've tried different things that haven't worked. Any help will be appreciated. This is what I have in my code now...I've commented out the different things i've tried/am trying.
ClearCollect(
colBudgetFilter,
If(
User().Email = varDeptHead,
Filter(
Budgets,
Department = varDept,
Conso = "Admin Costs",
Year = Text(Year(Today()))
),
Filter(
Budgets,
//Unit = "Facility" || Unit = "Horticulture",
//Unit = Concat(Gallery2.AllItems, Unit, "; "),
//ForAll(Gallery2.AllItems, Unit =
Conso = "Admin Costs",
Year = Text(Year(Today()))
)
)
);
Hi @AdaEloka ,
You can go a step further eliminating duplicated code
With(
{
_Data:
Filter(
Budgets,
Conso = "Admin Costs" &&
Year = Text(Year(Today()))
),
_Gal:
Concat(
Gallery2.AllItems,
Unit,
"; "
)
},
ClearCollect(
colBudgetFilter,
If(
User().Email = varDeptHead,
Filter(
_Data,
Department = varDept
),
Filter(
_Data,
varUnitHead ||
Unit in _Gal
)
)
)
)
@WarrenBelz Wow, this worked! Although I tweaked it a bit. But pls, could you explain the logic? I would like to understand it. Right now, I'm not sure why it worked, I just know it did...
This is my version of the code...
ClearCollect(
colBudgetFilter,
If(
User().Email = varDeptHead,
Filter(
Budgets,
Department = varDept,
Conso = "Admin Costs",
Year = Text(Year(Today()))
),
With(
{
_Data: Filter(
Budgets,
Conso = "Admin Costs" && Year = Text(Year(Today()))
),
_Gal: Concat(
Gallery2.AllItems,
Unit,
"; "
)
},
Filter(
_Data,
varUnitHead ||
Unit in _Gal
)
)
)
);
Thank you.
Hi @AdaEloka ,
Is this what you are trying to do ?
With(
{
_Data:
Filter(
Budgets,
Department = varDept &&
Conso = "Admin Costs" &&
Year = Text(Year(Today()))
),
_Gal: Concat(Gallery2.AllItems, Unit, "; ")
},
Filter(
_Data,
!varDeptHead ||
Unit in _Gal
)
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
MVP (Business Applications) Visit my blog Practical Power Apps