You could use some creative combination of substr(), pos() and length() functions to swap names. However, it would make the swap in every row, regardless of whether a row has first name on the first place and then last name or vice versa.
It’s better to do such manipulation of strings in the database (on the query level) rather than on a report level.
Its better to use substring() and pos() to achieve this. b’coz if you use
then a null will come in your name column which is not a good practice to have in DW project.
As your concept of data cleansing fails there. so better use what marek has written.
Refer to the link below for more info on these functions:
These links are from Web I but the functions mentioned here works in DeskI also.
Its better to use substring() and pos() to achieve this. b’coz if you use
then a null will come in your name column which is not a good practice to have in DW project.
As your concept of data cleansing fails there.
Cheers,
[/quote]
I would humbly disagree with your statement.
The Replace() function will identify for the text pointed and replace the identified text if found else the function would not make any effect on the data.
There is another solution to this… (for this particular scenario) where the “Sales” is a suffix to each name in the column.
=rtrim(;-Number of characters you want to remove)
in this scenario where the number of characters are fixed. For Sales = 5
so the formula becomes…
=rtrim((;-5)
Would had gone for that option if it had been just the text “Sales”
But the intial request criteria was department name. Hence I called for a replace() function. Again the replace() function didnt directly gave a soultion. As per PhilB, user did tweaking before getting what the final solution should be.
This can still be done using rtrim() …
for this create a variable which can calculate the length of the string to be removed. (say Var 1)
then user this in another variable Var 2 = rtrim([Name object];-[var1])
But still for this problem I feel Your suggestion of using replace fits the best. As it needs les effort and gives better performance.