Forum Discussion

mike_newbs's avatar
mike_newbs
Frequent Visitor
2 years ago
Solved

Apply value based on multiple values within a single cell

Hello,   I am creating a marketing report that segments customers based on their interest.   Products fall broadly into three category types:   Product Category Product 1, Product 3, Pro...
  • PijushRoy's avatar
    2 years ago

    Hi mike_newbs 

    Please use below DAX for calculated column (alter if you needs to change logic)

    Category = VAR _P1 = CONTAINSSTRING([Product interest], "Product 1")
    VAR _P2 = CONTAINSSTRING([Product interest], "Product 2")
    VAR _P3 = CONTAINSSTRING([Product interest], "Product 3")
    VAR _P4 = CONTAINSSTRING([Product interest], "Product 4")
    VAR _P5 = CONTAINSSTRING([Product interest], "Product 5")
    VAR _P6 = CONTAINSSTRING([Product interest], "Product 6")
    RETURN
    SWITCH(
        TRUE(),
        (_P1 = True || _P3 = True || _P6 = True) && NOT(_P2 = True || _P4 = True || _P5 = True),"Category 1",
        (_P2 = True || _P4 = True || _P5 = True) && NOT(_P1 = True || _P3 = True || _P6 = True),"Category 2",
        "Category 3")

     

     

    If solved your requirement, please mark this answer as SOLUTION.
    If this comment helps you, hit the LIKE 👍


    Thanks

    Pijush