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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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