Adding data to values in a data table

Hi all

I have 2 data tables which contain product and price information of shopping list items from 2 supermarkets. For practice, I’d like to loop through each data table and standardise the formatting of the prices so they are in the £x.xx format. Please can I have some advice on how to do this

Data table 1 (Tesco)

Prices show in the correct format, I just need to add a ‘£’ sign to each value (so 0.40 becomes £0.40 and 1.23 becomes £1.23)

Data table 2 (Morrisons)

This is a bit trickier. Any product that costs over £1 is already in the correct format (e.g £1.25). Products that are under £1 show in pence e.g 40p. How do I loop through the table, check if the price format is in ‘p’ and change it to ‘£’ so 40p would become £0.40. 68p would become £0.68 etc

Thanks in advance,
Jordan

Fine you were almost done
–use a for each row loop and hope you have a datatable ready named dt1 and pass that as input
–inside the loop use a assign acitivity like tis
row(“columnname”) = (“£”).ToString+row(“columnname”)
this will concatenate all the values with that notation

then for this

–use same for each row loop and a datatable named dt2 is passed to it
–use a if condition like this
row(“columnname”).tostring.contains(“p”)
if true then goes to THEN part where we can use a assign activity like this
assign activity like this
row(“columnname”) = (“£0.”).ToString+row(“columnname”).Replace(“p”,"")

Cheers @jordrowley

1 Like

You’re my hero! Thanks for all the help :slight_smile:
Jordan

1 Like

no worries
Cheers @jordrowley

Thank you, quick question. Is there an expression you can write in an assign activity to check if a data table has an data in? it’s so I can put it in an if statement before deciding if I need to paste the data from the data table in to an excel file. Ta!

yah of course, put this in if condition
yourdatatablename.Rows.Count>0
if true it goes to THEN part which means it has data or goes to ELSE

Cheers @jordrowley

1 Like

hey @Palaniyappan

Please can I ask if you know how I can fix this error, please

Thanks :slight_smile:
Jordan

1 Like

Out that row(“price”) in the left side of assigns nd remove that datatable name in the left side
Cheers @jordrowley

Thank you, i’m really sorry but now I get this error. Please can you advise. Thank you so much for helping.

Thanks
Jordan

1 Like

No worries
Remove the
row(“Price”) =

In the right side of assign
Cheers @jordrowley

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