cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MaxDonen
Level: Powered On

First vs FirstN expression

Ok, here's the obligatory 'I've already searched for this extensively, but sorry if it's been answered somewhere'...

 

I can get First() function to work just fine. I have used in a gallery on a static excel dataset ('bubbledata', 13 rows)  and it returns the first value as expected. Same for Last(). 

 

Eg: 

 

First(bubbledata).'Cost per m2 '

 

 

But the following syntax, used with FirstN, generates the error: "Expexted Text value. The property on this control expects text values. The rule produces Table values which are incompatible."

 

firstN(bubbledata,3).'Cost per m2'

I have searched high and low for a solution and got nowhere. Am I missing something? (Extremely likely.)

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support Team
Community Support Team

Re: First vs FirstN expression

Hi @MaxDonen ,

Based on the issue that you mentioned, I think you have some misunderstanding between the First function and FirstN function.

 

The First() function (or Last function) would retrieve the first record (or last record) from your data source, the returned result is an record. But the FirstN() function is used to return the first set of records of a table, the returned result is a table.

 

On your side, the result the FirstN(bubbledata, 3).'Cost per m2' formula returned is a single one column table rather than a Text value, so you could not type this formula within the Text property of a Label or the Default property of a Text Input box.

 

If you want to return the third record in your 'bubbledata' table data source, please consider modify your formula as below (set the Text property of a Label to following):

Last(FirstN(bubbledata, 3)).'Cost per m2'

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
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

Super User
Super User

Re: First vs FirstN expression

If you use First() with a single column you get just the value of that cell from the first record.  If you use FirstN() with a single column you get a Table of values, so its still a collection.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
Super User
Super User

Re: First vs FirstN expression

Here's what I think your problem is. First() will return one record, so the call to a specific field isn't ambiguous.  But FirstN returns multiple records as a collection.  So when you try to get a specific field PowerApps is going to try to give you a collection (table) of those fields.  But wherever you are using the value is expecting a single text value.  That's find with First() or Last(), but FirstN() won't give you a text value it will give you a collection of text values.

 

So the question is what are you trying to do with the values you are getting back with FirstN().  I need a bit more information about how you are trying to use it to give you a solution.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Community Support Team
Community Support Team

Re: First vs FirstN expression

Hi @MaxDonen ,

Based on the issue that you mentioned, I think you have some misunderstanding between the First function and FirstN function.

 

The First() function (or Last function) would retrieve the first record (or last record) from your data source, the returned result is an record. But the FirstN() function is used to return the first set of records of a table, the returned result is a table.

 

On your side, the result the FirstN(bubbledata, 3).'Cost per m2' formula returned is a single one column table rather than a Text value, so you could not type this formula within the Text property of a Label or the Default property of a Text Input box.

 

If you want to return the third record in your 'bubbledata' table data source, please consider modify your formula as below (set the Text property of a Label to following):

Last(FirstN(bubbledata, 3)).'Cost per m2'

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
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

MaxDonen
Level: Powered On

Re: First vs FirstN expression

Thanks-I think that solves my issue. But then, why does the first() function work when only a single column is specified? Surely it should work the same way as the firstN function, only with the first row rather than a set of rows being returned?

Super User
Super User

Re: First vs FirstN expression

If you use First() with a single column you get just the value of that cell from the first record.  If you use FirstN() with a single column you get a Table of values, so its still a collection.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 458 members 4,012 guests
Please welcome our newest community members: