Adding suffix to a number in excel

I have a numbers from 1 to 20 in a column in excel. I have to add suffix to it… Like 1st, 2nd… So on upto 20th and store in a seperate column, how do I do it ?
Can someone please help.

Thanks in advance

1 Like

Hi @Joywin.Madtha

When you iterate in your excel

using foreachrow.
item.ToString & condition.
as i can see you like to suffix st,nd,rd,th right ?
have you already try it.?

cheers :smiley:

Happy learning :smiley:

Yes that’s exactly.

1 Like

But I haven’t tried it. Can you please help me out with it

1 Like

I have to write the numbers in excel and then add suffix later on

1 Like

Yes its doable and it has a lot of condition on it.Is that exactly 1 to 20 only? @Joywin.Madtha

cheers :smiley:

Happy learning :smiley:

here you go the xaml
hope this would resolve your issue
suffix.zip (17.3 KB)

Cheers @Joywin.Madtha

Yes only 1 to 20

1 Like

The workflow is not running, shows an error

1 Like

what was the error
can i have a screenshot of that
@Joywin.Madtha

I guess @Palaniyappan will attend for your issue and i know for sure he can do it.!

cheers :smiley:

Happy learning :smiley:

@Palaniyappan I am using 2018 version

1 Like

Fine
the step involved is like below
–next to read range activity use a for each row loop and pass the variable dt as input (dt is the datatable variable obtained from read range activity)
–inside the for each row loop use a assign activity like this
row(0) = If(row(0).ToString.Equals(“1”),row(0).ToString+“st”,
If(row(0).ToString.Equals(“2”),row(0).ToString+“nd”,
If(row(0).ToString.Equals(“3”),row(0).ToString+“rd”,row(0).ToString+“th”)))

next to this for each row loop use a KILL PROCESS activity where in the property panel mention as “EXCEL” in the Process Name property.
–next use a WRITE RANGE ACTIVITY from workbook activities, where in the file path mention the excel file path and in the sheetname mention the sheetname and in range “” and in the datatable mention as dt and ensure that the ADD HEADERS property in the property panel of write range activity is enabled

Cheers @Joywin.Madtha
where

1 Like

row(0) = If(row(0).ToString.Equals(“1”),row(0).ToString+“st”,
If(row(0).ToString.Equals(“2”),row(0).ToString+“nd”,
If(row(0).ToString.Equals(“3”),row(0).ToString+“rd”,row(0).ToString+“th”)))

This entire thing is one assign activity ?
@Palaniyappan

1 Like

yah
row(0) in left side
and this in right side of assign activity
If(row(0).ToString.Equals(“1”),row(0).ToString+“st”,
If(row(0).ToString.Equals(“2”),row(0).ToString+“nd”,
If(row(0).ToString.Equals(“3”),row(0).ToString+“rd”,row(0).ToString+“th”)))

Cheers @Joywin.Madtha

1 Like

Thanks @Palaniyappan. Will try and let you know if any issues occur

1 Like

Cheers @pattyricarte

1 Like

Now there’s an issue, for numbers from 1 - 10, the sequence goes
1st, 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th, 10th

For 11-20 - 11th,12th, 13th, 14th, 15th, 16th, 17th, 18th, 19th, 20th

But after this, it again follows the same sequence as 1- 10 like
21-30: 21st, 22nd… And so on
What condition can I apply, so that when last index is between 11 and 20 I use th suffix otherwise follow regular method

1 Like

Could you please help me out with this @Palaniyappan

Thanks :blush:

1 Like

Fine then mention the condition like this
If(row(0).ToString.Endswith(“1”),row(0).ToString+“st”,
If(row(0).ToString.Endswith(“2”),row(0).ToString+“nd”,
If(row(0).ToString.Endswith(“3”),row(0).ToString+“rd”,row(0).ToString+“th”)))

Cheers @Joywin.Madtha