cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Prbhv
New Member

Extract first item from a listbox

Hi everyone,
 
I am displaying a listbox (containing multiple items) in my gallery, in every row.
I would like to extract the first item from each listbox (as a Text datatype) and save it in a different text label (of data type text). I do not want the user to have to manually select any item from the list box to do so.
I have tried First(Filter(Source,X=ThisItem.Result).Column_name) to make only the first item visible in my listbox and tried to convert into text using
Text(First(Filter(Source,X=ThisItem.Result).Column_name),Text) but even that doesn't work. Any help is appreciated. 
 
(PS: It is imperative we have it as text data type, currently I am seeing it as Control data type.)
1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Prbhv ,

Do you want to get the text value of the first item in the list box?
Could you tell me:
1)the items property of the list box?

2)the column data type?
I assume that your listbox items is Filter(Source,X=ThisItem.Result).

1)If the column is text type, you should use this formula:

First(Filter(Source,X=ThisItem.Result)).Column_name

First(...) will return the first record of the filtered table. First(..).columnname will be the field value in that item.

2)If the column is number type, you should use this formula:

Text(First(Filter(Source,X=ThisItem.Result)).Column_name)

 text() function will transfer number to text.

3)If the column is choice type, you should use this formula:

First(Filter(Source,X=ThisItem.Result)).Column_name.Value

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
eka24
Super User
Super User

Can you show a screenshot of the Gallery and on listbox.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

v-yutliu-msft
Community Support
Community Support

Hi @Prbhv ,

Do you want to get the text value of the first item in the list box?
Could you tell me:
1)the items property of the list box?

2)the column data type?
I assume that your listbox items is Filter(Source,X=ThisItem.Result).

1)If the column is text type, you should use this formula:

First(Filter(Source,X=ThisItem.Result)).Column_name

First(...) will return the first record of the filtered table. First(..).columnname will be the field value in that item.

2)If the column is number type, you should use this formula:

Text(First(Filter(Source,X=ThisItem.Result)).Column_name)

 text() function will transfer number to text.

3)If the column is choice type, you should use this formula:

First(Filter(Source,X=ThisItem.Result)).Column_name.Value

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,453)