Split comma separated values in column and add it in a new column

I have a table where I created a measure SourceOrderTag which can have 2 values as you can see in the table

07e34be8-467f-4f73-8f61-c3f9a5f656fc.png

The order of data coming in the column is not fix.

I want to take the Drop Order from both rows and put it in the Source column & DRTV - Warranty Replacement in Order_tag column

To do that I wrote this expression - 

case(when(count(split(${sourceordertag},",")) = 2,index(split(${sourceordertag},","),1)),null)

Using this expression the split is happening but its not exactly giving me the result I want.

Can anybody please help??

1 1 956
1 REPLY 1

I was able to achieve what I wanted using the below expression.

if(contains(${sourceordertag},"Drop Order"),"Drop Order",
    if(contains(${sourceordertag},"CLTM"),"CLTM",
        if(contains(${sourceordertag},"INTERNET"),"INTERNET",
            if(contains(${sourceordertag},"Five9 Chat"),"Five9 Chat",
                if(contains(${sourceordertag},"Five9 Email"),"Five9 Email",
                    if(contains(${sourceordertag},"WalmartCA"),"WalmartCA",null))))))


if(contains(${sourceordertag},"DRTV - Warranty Replacement"),"DRTV - Warranty Replacement",
    if(contains(${sourceordertag},"DRTV - Reship"),"DRTV - Reship",
        if(contains(${sourceordertag},"DRTV - GoodWill"),"DRTV - GoodWill",
            if(contains(${sourceordertag},"Retail - Warranty Replacement"),"Retail - Warranty Replacement",null))))

But this is not completely optimized solution but it works for me. If anyone can help me in making it more optimized that will be helpful..

But for now this works as expected

Top Labels in this Space
Top Solution Authors