Forum Discussion

sharmisaranga09's avatar
2 years ago
Solved

Find maximum occurred item for each category

Hi,

I have a question and answer columns in my table, I want to find the count of unique answers for each questions and get the maximum count answer for each question

Expected result is, find maximum answered Answer text for each question

 

  • Greg_Deckler's avatar
    Greg_Deckler
    2 years ago

    sharmisaranga09 The measure form is:

    Max count Answered (measure) =
      VAR __Question = MAX( [Question] )
      VAR __Table = SUMMARIZE( FILTER( ALL( 'Table' ), [Question] = __Question ), [Answer], "__Count", COUNTROWS( 'Table' ) )
      VAR __Max = MAXX( __Table, [__Count] )
      VAR __Result = MAXX( FILTER( __Table, [__Count] = __Max ), [Answer] )
    RETURN
      __Result

4 Replies

  • Hi,

     

    You can achieved this in Power Query by doing a Group by:

     

     

     

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

     

     

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    sharmisaranga09 Try this:

    Max count Answered (column) =
      VAR __Question = [Question]
      VAR __Table = SUMMARIZE( FILTER( 'Table', [Question] = __Question ), [Answer], "__Count", COUNTROWS( 'Table' ) )
      VAR __Max = MAXX( __Table, [__Count] )
      VAR __Result = MAXX( FILTER( __Table, [__Count] = __Max ), [Answer] )
    RETURN
      __Result
    • Greg_Deckler's avatar
      Greg_Deckler
      Icon for Community Champion rankCommunity Champion

      sharmisaranga09 The measure form is:

      Max count Answered (measure) =
        VAR __Question = MAX( [Question] )
        VAR __Table = SUMMARIZE( FILTER( ALL( 'Table' ), [Question] = __Question ), [Answer], "__Count", COUNTROWS( 'Table' ) )
        VAR __Max = MAXX( __Table, [__Count] )
        VAR __Result = MAXX( FILTER( __Table, [__Count] = __Max ), [Answer] )
      RETURN
        __Result