cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

How can I select a row from a DatTable using the Row number?

I am creating a datatable by splitting a string input value:

 

ClearCollect(splitem,Split(globScanResult," "));

 

My DataTable uses this collection as Data source.

 

splitstring.PNG

 

 

 

Row 1 is an ID

Row 2 is the Year

Row 3 is the Week

 etc

 

I want to use these row numbers to obtain the data, but cannot find the correct format.

I tries these, but it marks them as invalid:

 

Set(globId, Result_Column1.Text[1])

Set(globId, Result_Column1.Text(1))

 

What is the correct method? The documentation is not clear on this.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: How can I select a row from a DatTable using the Row number?

Hi @stapes 

The typical way to retrieve a row by row number is to use the Last/FirstN technique. For example, here's the syntax to retrieve row number 2.

Last(FirstN(splitem,2))

What this formula does is to retrieve the first 2 rows from splitem with the FirstN function. The Last function then returns the last record from this resultset, in this case, row 2.

Hope that's of some help.

View solution in original post

3 REPLIES 3
Highlighted
Super User
Super User

Re: How can I select a row from a DatTable using the Row number?

Hi @stapes 

The typical way to retrieve a row by row number is to use the Last/FirstN technique. For example, here's the syntax to retrieve row number 2.

Last(FirstN(splitem,2))

What this formula does is to retrieve the first 2 rows from splitem with the FirstN function. The Last function then returns the last record from this resultset, in this case, row 2.

Hope that's of some help.

View solution in original post

Highlighted
Post Patron
Post Patron

Re: How can I select a row from a DatTable using the Row number?

Thanks @timl . I actually settled for this:

 

ClearCollect(splitem,Split(globScanResult," ")); Set(globID, First(splitem).Result); Remove(splitem,FirstN(splitem,1)); Set(globYear, First(splitem).Result); Remove(splitem,FirstN(splitem,1)); Set(globWeekNo, First(splitem).Result); Remove(splitem,FirstN(splitem,1)); Set(globStockCode, First(splitem).Result); Remove(splitem,FirstN(splitem,1)); Set(globFillCode, First(splitem).Result); Remove(splitem,FirstN(splitem,1)); ClearCollect(splitem,Split(globScanResult," "));

Highlighted
Super User
Super User

Re: How can I select a row from a DatTable using the Row number?

I like what you've done here @stapes! That is, to work through a collection by recursively retrieving and deleting the first row. Thanks for sharing this 🙂

 

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (7,547)