I was asked to work on Alteryx.
I have a challenge with automating data cleaning.
I want to automatically clean extra delimiters in the description columns of concatenated BSEG_BKPF tables from SAP.
I can handle cases where a description column has extra delimiters using this Formula :
IF Length([Field_1])-Length(Replace([Field_1], "|", "")) > [NB délimiteur attendu] then Left([Field_1], FindNth([Field_1], "|", [Premier "|"])+1) + REPLACE( SUBSTRING( [Field_1], FindNth([Field_1], "|", [Premier "|"]) , Length([Field_1])-FindNth(ReverseString([Field_1]), "|", [Dernier "|"])-FindNth([Field_1], "|", [Premier "|"])),"|","")+ Right( [Field_1], FindNth(ReverseString([Field_1]), "|", [Dernier "|"])+1) else [Field_1] endif
Where :
[Premier "|"]) = Length( Left([Field_1], FindString([Field_1], "SGTXT"))) - Length(Replace(Left([Field_1], FindString([Field_1], "SGTXT")), "|", ""))
[Dernier "|"] = Length( Left(ReverseString([Field_1]), FindString(ReverseString([Field_1]), "TXTGS"))) - Length(Replace(Left(ReverseString([Field_1]), FindString(ReverseString([Field_1]), "TXTGS")), "|", ""))
This allows me, based on the headers, to know how many normal delimiters surround my description column.
This position-based formula does not work when more than one description column is malformed.
If you have any ideas using Alteryx or another language, I would be very grateful.