Forum Discussion

Mncedi's avatar
Mncedi
Regular Visitor
3 years ago
Solved

Customer segmentation

I have a dataset that has customer classifications based on recognized behavior. The most frequent behave is ranked 1. Some customers have a rank of 1 in two different classifications, meaning same frequent behavior recognized. I want to return classes that has rank 1 and in case there are different classes with rank 1, assign label = 'behavior not yet recognized'. If the rank > 1, label = blank. 

Customer IDClassRankLabel
1265move to A 1Behavior not Yet Recognized
1265move to A1Behavior not Yet Recognized
3489move to B1move to B
1265move to C3 
    
  • something like this?

     

     

     

    Label 1 = 
    VAR _c = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Rank],'Table'[Customer ID]))
    RETURN
    SWITCH(
        TRUE(),
        AND( 'Table'[Rank] = 1 , _c >1) , "Behavior Not Recogonized" ,
        AND('Table'[Rank] = 1 , _c = 1) , 'Table'[Class],
        BLANK()
    )

     

     

7 Replies

  • Hello Mncedi ,

     

    if you mean you want a dax measure that you can add on a calculated column then use the following:

     

    Label = if ( 'YourTableName'[Rank] = 1,"behavior not yet recognized",if ( 'YourTableName'[Rank] > 1,

    BLANK()))
     

    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

    Follow me on Linkedin

  • eliasayyy's avatar
    eliasayyy
    Memorable Member

    i think a simple if measure will solve your issue

     

    Measure = 
    IF(MAX('Table'[Rank]) = 1 , "Behavior Not yet Recognized")


    while in a calculated column 


     

    Measure = 
    IF('Table'[Rank] = 1 , "Behavior Not yet Recognized")​
  • Mncedi's avatar
    Mncedi
    Regular Visitor

    Thank you so much for your kind response@Idrissshatila 

    Maybe let me rephrase my question. I have some customers in the table who happen to have say two frequent classes that have the same rank of 1. If the customer has rank =1 then return the corresponding class. However, if the customer has two or more classes that have the same rank I want to assign them " behavior not yet recognized". Otherwise if class has rank =1 and other classes have rank >1 then return class with rank =1. 

    • eliasayyy's avatar
      eliasayyy
      Memorable Member

      thank you for clarifying please try 

      for measure

       

       

      Label = 
      VAR _c = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Class],'Table'[Rank]))
      RETURN
      SWITCH(
          TRUE(),
          AND( MAX('Table'[Rank]) = 1 , _c >1) , "Behavior Not Recogonized" ,
          AND(MAX('Table'[Rank]) = 1 , _c = 1) , MAX('Table'[Class]),
          BLANK()
      )

       

       

       

      for calculated column 

       

       

      Label 1 = 
      VAR _c = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Class],'Table'[Rank]))
      RETURN
      SWITCH(
          TRUE(),
          AND( 'Table'[Rank] = 1 , _c >1) , "Behavior Not Recogonized" ,
          AND('Table'[Rank] = 1 , _c = 1) , 'Table'[Class],
          BLANK()
      )

       

       



       

      please leave a thumbs up if i helped you solve your question

      • Mncedi's avatar
        Mncedi
        Regular Visitor

        Thanks once again.

        Sorry, I made a mistake, the customer has different classes of the same rank of 1.

        CustIDClassRank
        33445Move to A1
        33445Move to B1
        45657Move to B1

         

        I want to assign a calculated column or measure that will return for me the class when the rank is 1. For customers like the one of ID 33445, that have the same rank of 1 but have different classes, return "behavior not recognized".