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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DW868990
Helper IV
Helper IV

Dax to Return Most Common Value out of Combinations.....

Hi,

 

I am looking for the correct DAX logic for the below situation, I have a table like below:

DW868990_0-1662735708855.png

I am looking for the DAX calculation to dynamically calculate the overall rating for each customer, based on the result in the 5 events. So for the 'Overall' to be the most common answer, however on cases were the 2 answers are tied and there is no clear most common value for the Overall value to be the highest rating.

Ie - customer has 2 awful ratings, 2 amazing, 1 poor - So the overall rating would be amazing.

 

Thanks in advance.

 

Dave

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@DW868990 A few problems with this. What defines better rating? I guess you could hard code it. Also, is that the way your data looks? It would be a lot easier if you unpivoted the Event columns, otherwise it will be sadness to code. If you unpivot then it will look something like:

Overall Measure =
  VAR __Table = SUMMARIZE('Table',[Event Rating],"__Count",COUNTROWS('Table')
  VAR __Max = MAXX(__Table,[__Count])
  VAR __Table1 = FILTER(__Table, [__Count] = __Max)
  VAR __CountRows = COUNTROWS(__Table1)
  VAR __Rating = MAXX(__Table1,[Event Rating])
RETURN
  IF(
    __CountRows = 1, 
    __Rating,
    SWITCH(TRUE(),
      "Amazing" IN SELECTCOLUMNS(__Table1,"Rating",[Event Rating]),"Amazing",
      "Okay" IN SELECTCOLUMNS(__Table1,"Rating",[Event Rating]),"Okay",
      "Poor" IN SELECTCOLUMNS(__Table1,"Rating",[Event Rating]),"Poor",
      "Awful"
    )
  )
      


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@DW868990 A few problems with this. What defines better rating? I guess you could hard code it. Also, is that the way your data looks? It would be a lot easier if you unpivoted the Event columns, otherwise it will be sadness to code. If you unpivot then it will look something like:

Overall Measure =
  VAR __Table = SUMMARIZE('Table',[Event Rating],"__Count",COUNTROWS('Table')
  VAR __Max = MAXX(__Table,[__Count])
  VAR __Table1 = FILTER(__Table, [__Count] = __Max)
  VAR __CountRows = COUNTROWS(__Table1)
  VAR __Rating = MAXX(__Table1,[Event Rating])
RETURN
  IF(
    __CountRows = 1, 
    __Rating,
    SWITCH(TRUE(),
      "Amazing" IN SELECTCOLUMNS(__Table1,"Rating",[Event Rating]),"Amazing",
      "Okay" IN SELECTCOLUMNS(__Table1,"Rating",[Event Rating]),"Okay",
      "Poor" IN SELECTCOLUMNS(__Table1,"Rating",[Event Rating]),"Poor",
      "Awful"
    )
  )
      


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

ah yes, can unpivot column no bother and this should do the trick! thank you 🙂

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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