Forum Discussion

abhi1234's avatar
abhi1234
Regular Visitor
3 years ago
Solved

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
Model2023
Model 12
Model21
  
User selects Fetr A & B
Model2023
Model 12
Model 21
  
User selects Fetr A, B & C
Model2023
Model 11
Model 20

 

 

ModelFeatureVinDate
Model 1FetrAVIN18/12/2023
Model 1FetrBVIN18/12/2023
Model 1FetrCVIN18/12/2023
Model 1FetrDVIN18/12/2023
Model 1FetrAVIN28/12/2023
Model 1FetrBVIN28/12/2023
Model 1FetrCVIN38/11/2023
Model 1FetrDVIN38/11/2023
Model 2FetrAVIN48/10/2023
Model 2FetrBVIN48/10/2023
Model 2FetrCVIN58/10/2023
Model 2FetrDVIN58/10/2023

6 Replies

    • abhi1234's avatar
      abhi1234
      Regular 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...

      • parry2k's avatar
        parry2k
        Super User

        ThxAlot great solution but unfortunaltey the total will never be correct, if that is not the requirement then it is a good solution. Well done! 

  • 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 __count

     

    To 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! ❤️