Forum Discussion
trying to get count based on combinations
below is my sample data, I am trying to get a count based on feature combinations.
desired result, based on user selected filters:
| User selects Fetr A | |
| Model | 2023 |
| Model 1 | 2 |
| Model2 | 1 |
| User selects Fetr A & B | |
| Model | 2023 |
| Model 1 | 2 |
| Model 2 | 1 |
| User selects Fetr A, B & C | |
| Model | 2023 |
| Model 1 | 1 |
| Model 2 | 0 |
| Model | Feature | Vin | Date |
| Model 1 | FetrA | VIN1 | 8/12/2023 |
| Model 1 | FetrB | VIN1 | 8/12/2023 |
| Model 1 | FetrC | VIN1 | 8/12/2023 |
| Model 1 | FetrD | VIN1 | 8/12/2023 |
| Model 1 | FetrA | VIN2 | 8/12/2023 |
| Model 1 | FetrB | VIN2 | 8/12/2023 |
| Model 1 | FetrC | VIN3 | 8/11/2023 |
| Model 1 | FetrD | VIN3 | 8/11/2023 |
| Model 2 | FetrA | VIN4 | 8/10/2023 |
| Model 2 | FetrB | VIN4 | 8/10/2023 |
| Model 2 | FetrC | VIN5 | 8/10/2023 |
| Model 2 | FetrD | VIN5 | 8/10/2023 |
6 Replies
- ThxAlotSuper User
- abhi1234Regular Visitor
Thank you! That does calculate combinations based on selected features... I am going to try to build on it to see if I can generate a forecast...
- parry2kSuper User
abhi1234 you need to tweak your model a bit, and add another table, let's call it Model which will have all the unique values of the Model column. Set the relationship of this table with the transaction table on the model column. Add the following measure:
Model with Selected Features = VAR __featuresSelected = COUNTROWS ( ALLSELECTED ( 'Table'[Feature] ) ) VAR __modelwithFeature = SUMMARIZE ( 'Table', 'Table'[Vin], "@Cnt", COUNT ( 'Table'[Feature] ) ) VAR __count = SUMX ( __modelwithFeature, INT ( [@Cnt] = __featuresSelected ) ) RETURN __countTo visualize, add Model column from the new table and above measure and that will give you the expected result.
👉 Learn Power BI and Fabric - subscribe to our YT channel - @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! ❤️
- Ashish_MathurSuper User