cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Continued Contributor
Continued Contributor

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
Super User III
Super User III

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
Super User III
Super User III

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

Continued Contributor
Continued Contributor

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," "));

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,674)