Forum Discussion
Anonymous
6 years agoNot applicable
Customer classification logic
Hi all, I'm trying to create logic for a new column Customer Type: Customer Type classification -> Indoor, Outdoor, Both if all Actual instances of a customer are Indoor --> customer type is In...
- 6 years ago
Anonymous try something like this, add this as a column
Ask anything Power BI. Book appointment for a free consultancy at https://www.perytus.com
Customer Type = VAR __indoor = COUNTROWS( CALCULATETABLE( VALUES ( Customer[Product type] ), ALLEXCEPT ( Customer, Customer[Customer] ), Customer[Product type] = "Indoor" , CONTAINSSTRING( Customer[Status] , "Actual" ) ) ) VAR __outdoor =COUNTROWS( CALCULATETABLE( VALUES ( Customer[Product type] ), ALLEXCEPT ( Customer, Customer[Customer] ), Customer[Product type] = "Outdoor" , CONTAINSSTRING( Customer[Status] , "Actual" ) ) ) RETURN SWITCH ( TRUE(), __indoor = 1 && __outdoor = 1, "Both", __indoor = 1, "Indoor", __outdoor = 1, "Outdoor" )Would appreciate Kudos 🙂 if my solution helped.
parry2k
Super User
6 years agoAnonymous customer A suppose to be Both, isnt it?
Ask anything Power BI. Book appointment for a free consultancy at https://www.perytus.com
- Anonymous6 years agoNot applicable
parry2k no, I want to ignore where status = Test, I only want to look at where Status contains the text "Actual"
- camargos886 years ago
Community Champion
Hi Anonymous ,
Try this code:
Column =VAR _result = CALCULATE(DISTINCTCOUNT('Table'[Product type]); FILTER(ALLEXCEPT('Table';'Table'[Customer]); SEARCH("Actual"; 'Table'[Status]; 1;0) > 0))RETURN IF(_result = 1; CALCULATE(DISTINCT('Table'[Product type]); FILTER(ALLEXCEPT('Table';'Table'[Customer]); SEARCH("Actual"; 'Table'[Status]; 1;0) > 0)); "Both")Ricardo