cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Retrieve Value from first record of table

Having trouble declaring variable from first row in datasource.  

 

Ideally, using something like the following should return the desired_value from the datasource.  

 

error suggests invalid arguments.

 

datasource: SQL

datatype: varchar(15)

 

 

set(firstValue,text(datasource.desired_value)) 
1 ACCEPTED SOLUTION

Accepted Solutions
Resolver II
Resolver II

I think you are looking for something like this

Set(VarNameHere, First(DataSourceNameHere).ColumnNameHere)

If you want the complete row just remove the .ColumnNameHere snippet. Obviously replace values with a variable name, datasource name and column name.

Initiate from an OnSelect action or OnVisible page action.

Thanks
Luke

View solution in original post

3 REPLIES 3
Dual Super User III
Dual Super User III

There is an actual function available in PowerApps that will return the first record in a data source. You'll preferably want to filter the data source to a subset of records that you know will contain the first record.

First(datasource)


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

I think you are looking for something like this

Set(VarNameHere, First(DataSourceNameHere).ColumnNameHere)

If you want the complete row just remove the .ColumnNameHere snippet. Obviously replace values with a variable name, datasource name and column name.

Initiate from an OnSelect action or OnVisible page action.

Thanks
Luke

View solution in original post

This was exactliy what I was looking for @Luke_Timmins 

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (84,747)