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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
powerBIpeon
Helper II
Helper II

formula to group customers based on items they have

Is there a formula to assign a customer to a group based on certian items they have? If the customer has one of the bold letter items in the group below they will automatically be assigned to that group even if they have other items that are not in bold letters

 

Data set 1

Group 1 - car, house, bike, motorcycle

Group 2 - car, boat

Group 3 - house, motorcycle

 

Data set 2

David - house, motorcycle, bike

John - car, boat

Mike - house, car

 

Return value

David = Group 1

John = Group 2

Mike = Group 3

 

Thanks in advance!

1 ACCEPTED SOLUTION
Seward12533
Solution Sage
Solution Sage

Is this a Measure or Calc Column? 

 

If its a column then this should work - not sure how your data is organized so I took a guess.  after I wrote the below I  rememberd you can probalby use the IN {"house","car"} vs the || operator but I think you will get the approach.  If you need more help can you can share your model and table layout even if its just the field names and header rows and give a better idea of the resutls your after.

 

Group Column = SWITCH(TRUE(),
     CALCULATE(COUNTROWS(VALUES(policies[PolicyType]), FILTER(policies,policy[type]="car"||policy[type]="house"||policy[type]="bike"||policy[type]="motorcycle")=4,"1",
     CALCULATE(COUNTROWS(VALUES(policies[PolicyType]), FILTER(policies,policy[type]="car"||policy[type]="boat"||=2,"2"
….


 

View solution in original post

4 REPLIES 4
Seward12533
Solution Sage
Solution Sage

Is this a Measure or Calc Column? 

 

If its a column then this should work - not sure how your data is organized so I took a guess.  after I wrote the below I  rememberd you can probalby use the IN {"house","car"} vs the || operator but I think you will get the approach.  If you need more help can you can share your model and table layout even if its just the field names and header rows and give a better idea of the resutls your after.

 

Group Column = SWITCH(TRUE(),
     CALCULATE(COUNTROWS(VALUES(policies[PolicyType]), FILTER(policies,policy[type]="car"||policy[type]="house"||policy[type]="bike"||policy[type]="motorcycle")=4,"1",
     CALCULATE(COUNTROWS(VALUES(policies[PolicyType]), FILTER(policies,policy[type]="car"||policy[type]="boat"||=2,"2"
….


 

Thanks all!

parry2k
Super User
Super User

What happens if person has both bold items belongs to diffrent groups, what group he will be assigned in that case?



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.

They would be assigned to the highest group.

 

The Ranking would be Group 1 > Group 2 > Group 3

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.