When a value in column B appears multiple times against a value in Column A concatenate those values

Hi

I'm really struggling with my dataset as I have a many to one relationship between the DIVISION and CUSTOMER columns which causes issue with grouping later in the ETL

How do I write a formula which will affix the Customer name with the Division name if the customer appears against 2 or more Divisions else if the Customer to Division is 1:1 then leave Customer asis

Thanks

Dan

Answers

  • I think something like this would work:

    CASE

    WHEN COUNT(DISTINCT Division) FIXED (BY Customer) >1 then CONCAT(`Customer`, '-', Division)

    else CONCAT(Customer)

    END

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.