Forum Discussion

donglanmao1996's avatar
donglanmao1996
Frequent Visitor
3 years ago
Solved

Filter by multiple columns and customer segment

Hallo, I am power bi beginner and I have a problem with filter: so I want to differentiate customers, who has product sku 1 in their first order, sku 2 in their first order, sku 3 in their first order etc.  Please see the example photo below. And how can I save this customer segment for future use, like put customer a and b in one "container” as they have sku 1 in their first order; put customer a and c in another container...

 

thank you very much!

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  donglanmao1996 ,

     

    Here are the steps you can follow:

    1. Create calculated column.

    Rank = LEFT('Table'[Index],1)

    2. Create measure.

    Flag =
    VAR _SELECT=SELECTEDVALUE('Table2'[Produce])
    var _column=
    MAXX(FILTER(ALL('Table'),
    'Table'[Customer]=MAX('Table'[Customer])&&'Table'[Index]=MINX(FILTER(ALL('Table'),'Table'[Customer]=MAX('Table'[Customer])),[Index])),[Product])
    RETURN
    IF(
    CONTAINSSTRING(_column,_SELECT)=TRUE(),1,0)

    3. Place [Flag]in Filters, set is=1, apply filter.

    4. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  donglanmao1996 ,

     

    Here are the steps you can follow:

    1. Create calculated column.

    Rank = LEFT('Table'[Index],1)

    2. Create measure.

    Flag =
    VAR _SELECT=SELECTEDVALUE('Table2'[Produce])
    var _column=
    MAXX(FILTER(ALL('Table'),
    'Table'[Customer]=MAX('Table'[Customer])&&'Table'[Index]=MINX(FILTER(ALL('Table'),'Table'[Customer]=MAX('Table'[Customer])),[Index])),[Product])
    RETURN
    IF(
    CONTAINSSTRING(_column,_SELECT)=TRUE(),1,0)

    3. Place [Flag]in Filters, set is=1, apply filter.

    4. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly