Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Customer classification logic

Hi all, I'm trying to create logic for a new column Customer Type:

 

Customer Type classification -> Indoor, Outdoor, Both

  1. if all Actual instances of a customer are Indoor --> customer type is Indoor
  2. if all Actual instances are Outdoor --> customer type is Outdoor
  3. if some Actual instances are Indoor and some are Outdoor or null  --> Both

Please note that I want to ignore all customers with Status that does contain the text "Actual"

CustomerStatusProduct typeCustomer Type (desired column)
ATestIndoorOutdoor
AActual1OutdoorOutdoor
AActual2OutdoorOutdoor
BActual1IndoorIndoor
BTestIndoorIndoor
BActual2IndoorIndoor
CActual1OutdoorBoth
CActual2 Both
CActual 3IndoorBoth

Could someone help me figure out how to implement this logic in a new column? Thanks!

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@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.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@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.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous customer A suppose to be Both, isnt it?

 

Ask anything Power BI. Book appointment for a free consultancy at https://www.perytus.com



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k no, I want to ignore where status = Test, I only want to look at where Status contains the text "Actual"

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


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors