How to fetch random row items from one datatable and put it in other data table

Hi ,

I need some help regarding fetching random row items from one datatable and put it in other data table.

Thank you

can you elaborate more on what is meant with random row items? Thanks

Hey @Iptita_Sahu

You can always try with
DataTable.Rows(0).Item(0) ---------- picks up the first column value in the sheet

And paste the same in the next sheet or excel using “Write Cell” activity

Hi ppr

Lets say this is tha base table,

Name------Value
Bot1--------1
Bot2--------2
Bot3--------3
Bot4--------4
Bot5--------5

If i want the bot to pick 3 random rows from the datatable for example,

Name------Value
Bot1--------1
Bot3--------3
Bot4--------4

And put it in another Datatable

It should not be picked serially but randomly.

Regards,
Iptita

Hi Goutham,

Can you please elaborate the solution, I could not follow you up

Regards,
Iptita

Updated XAML below

Hi ppr,

I tried the RandomRowsRetrival.xaml, But its not working for me. Its replacing my original values in the db.

Thank you

let me check one thing, but it will not replace it will extract random rows

Sure

@Iptita_Sahu
Variables:
grafik

Dummy Count is used for the testdata set generation - you do not need as you are working over your datatable

SampleSet = the numbers of rows you want to extract randomly

Flow: Creating the random list of row indexes:
grafik
it will as long generate indexes till we do reached the defined count of unique random indexes

Flow Extraction:
grafik

So from a datatable with x rows -dtData it is extracting y random rows and you can refer to it on dtDataExtracted:

instead of dtData just use your datatable. The automatic generated test rows part can be removed from xaml

find starter help xaml here:
RandomRowsRetrieval_V2.xaml (10.1 KB)

Hi ppr,
I tried the way u told, but still getting this o/p. Its replacing my datas in DB

image

when you see on the xaml and also on the screenshot it is not modifying the origin datatable and deleting the original data.

Is it ensured that you are doing the row extraction on a second datatable?

Ensure also that the part, where the dummy data is generated (helper xaml, demo purpose) is not integrated within your implementation. Go for a correct integration of the relevant parts

feel free to share your xaml with us

I tried again it worked for me thank you so much for your help ppr

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.