Forum Discussion
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 ID | Class | Rank | Label |
| 1265 | move to A | 1 | Behavior not Yet Recognized |
| 1265 | move to A | 1 | Behavior not Yet Recognized |
| 3489 | move to B | 1 | move to B |
| 1265 | move to C | 3 | |
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
- IdrissshatilaSuper User
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 👍
- eliasayyyMemorable 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 columnMeasure = IF('Table'[Rank] = 1 , "Behavior Not yet Recognized") - MncediRegular 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.
- eliasayyyMemorable Member
thank you for clarifying please try
for measureLabel = 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
- MncediRegular Visitor
Thanks once again.
Sorry, I made a mistake, the customer has different classes of the same rank of 1.
CustID Class Rank 33445 Move to A 1 33445 Move to B 1 45657 Move to B 1 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".