I'm trying to populate a single-select dropdown box with a list of unique names that come from a multiple values People or Groups field in SharePoint. If there's a blank entry, I want to convert it to the text "Unspecified". I also want the dropdown to have an "All People" entry.
I'm thinking that I need to end up with a table of distinct values for the dropdown, but the source data is in a record format. So how can I convert a record into a table? Can you provide any guidance?
Note: I'll use the dropdown box to filter the results of a gallery.
Thanks.
Solved! Go to Solution.
Use the following formula on the Items property to get what you want:
With({_people:
ForAll(
DropColumns(
GroupBy(
ShowColumns(
Ungroup(
YourDataSource.MultiplePersonColumnName,
"MultiPerson"
),
"DisplayName", "Email"
),
"DisplayName", "Email", "_records"
),
"_records"
) As _person,
Patch(_person, {DisplayName: Coalesce(_person.DisplayName, "Unspecified")})
)
},
Ungroup(
Table({Items: Table({DisplayName:"All People"})},
{Items: _people}
),
"Items"
)
)
Replace YourDataSource.MultiplePersonColumnName in the formula to the name of your datasource and the column name.
I hope this is helpful for you.
Use the following formula on the Items property to get what you want:
With({_people:
ForAll(
DropColumns(
GroupBy(
ShowColumns(
Ungroup(
YourDataSource.MultiplePersonColumnName,
"MultiPerson"
),
"DisplayName", "Email"
),
"DisplayName", "Email", "_records"
),
"_records"
) As _person,
Patch(_person, {DisplayName: Coalesce(_person.DisplayName, "Unspecified")})
)
},
Ungroup(
Table({Items: Table({DisplayName:"All People"})},
{Items: _people}
),
"Items"
)
)
Replace YourDataSource.MultiplePersonColumnName in the formula to the name of your datasource and the column name.
I hope this is helpful for you.
It worked! Thanks so much for the quick response.
No problem! Glad it helped!
User | Count |
---|---|
256 | |
103 | |
92 | |
47 | |
37 |