
Announcements
Morning all,
I'm creating a glossary gallery that can be filtered to show items based on what they start with. As space is at a premium, I've grouped the letters to ranges, as below:
ClearCollect(alph,
{Letter: "A", Grp: "A-F"},
{Letter: "B", Grp: "A-F"},
{Letter: "C", Grp: "A-F"},
{Letter: "D", Grp: "A-F"},
{Letter: "E", Grp: "A-F"},
{Letter: "F", Grp: "A-F"},
{Letter: "G", Grp: "G-L"},
{Letter: "H", Grp: "G-L"},
{Letter: "I", Grp: "G-L"},
{Letter: "J", Grp: "G-L"},
{Letter: "K", Grp: "G-L"},
{Letter: "L", Grp: "G-L"},
{Letter: "M", Grp: "M-R"},
{Letter: "N", Grp: "M-R"},
{Letter: "O", Grp: "M-R"},
{Letter: "P", Grp: "M-R"},
{Letter: "Q", Grp: "M-R"},
{Letter: "R", Grp: "M-R"},
{Letter: "S", Grp: "S-X"},
{Letter: "T", Grp: "S-X"},
{Letter: "U", Grp: "S-X"},
{Letter: "V", Grp: "S-X"},
{Letter: "W", Grp: "S-X"},
{Letter: "X", Grp: "S-X"},
{Letter: "Y", Grp: "Y-#"},
{Letter: "Z", Grp: "Y-#"},
{Letter: "#", Grp: "Y-#"}
)
)
There are buttons that correspond to the letter ranges and the gallery will be filtered to show all letters within the selected range. Now, I can get it to work this way, with Table1 being my glossary data source:
If(
suggested.Title = "Glossary",
Switch(true,
glossarySortOrder = "A-F", Filter(Table1,
StartsWith(Acronym, "A") ||
StartsWith(Acronym, "B") ||
StartsWith(Acronym, "C") ||
StartsWith(Acronym, "D") ||
StartsWith(Acronym, "E") ||
StartsWith(Acronym, "F")),
glossarySortOrder = "G-L", Filter(Table1,
StartsWith(Acronym, "G") ||
StartsWith(Acronym, "H") ||
StartsWith(Acronym, "I") ||
StartsWith(Acronym, "J") ||
StartsWith(Acronym, "K") ||
StartsWith(Acronym, "L")),
glossarySortOrder = "M-R", Filter(Table1,
StartsWith(Acronym, "M") ||
StartsWith(Acronym, "N") ||
StartsWith(Acronym, "O") ||
StartsWith(Acronym, "P") ||
StartsWith(Acronym, "Q") ||
StartsWith(Acronym, "R")),
glossarySortOrder = "S-X", Filter(Table1,
StartsWith(Acronym, "S") ||
StartsWith(Acronym, "T") ||
StartsWith(Acronym, "U") ||
StartsWith(Acronym, "V") ||
StartsWith(Acronym, "W") ||
StartsWith(Acronym, "X")),
glossarySortOrder = "Y-#", Filter(Table1,
StartsWith(Acronym, "Y") ||
StartsWith(Acronym, "Z") ||
IsNumeric(Acronym)),
Table1),
Filter(
Table1,
suggested.Title in Trim(Split(Category,";"))))
But i realise this means my collections only really needs to contain my five letter groups and not the corresponding letter. So what I need is it to compare the start of the Acronym against the letters within the selected group. I've managed to get this to work:
glossarySortOrder = "A-F", Filter(Table1,
StartsWith(Acronym, LookUp(alph, Grp = "A-F").Letter)),
But this just returns, for example, any item that begins with A.
Is it possible to have StartsWith compare against a range of values, or am I barking up the wrong tree here?
Hi @EpicTriffid :
Please modify the Filter formula to:
Filter(
Table1,
Sum(
ForAll(
Filter(
alph,
Grp = "A-F"
),
If(
StartsWith(
Acronym,
Letter
),
1,
0
)
),
Value
) > 0
)
I've made a test for your reference:
1\My Table1:
ClearCollect(
Table1,
{Acronym:"AXXX"},
{Acronym:"CXXXX"},
{Acronym:"DXXXX"},
{Acronym:"EXXXXX"},
{Acronym:"VXXXXX"},
{Acronym:"XXXX"},
{Acronym:"GXXXXX"},
{Acronym:"FXXXXX"}
)
2\Add a data table control and set it's Items property to:
Filter(
Table1,
Sum(
ForAll(
Filter(
alph,
Grp = "A-F"
),
If(
StartsWith(
Acronym,
Letter
),
1,
0
)
),
Value
) > 0
)
Best Regards,
Bof