Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Average for Unique IDs per category and Total

Hi Community,

I am trying to create a measure that will calculate average for each unique case per category and for total, for the unpivoted table that has one row per category for each case (one case has 5 rows, but only some of those rows are applicable).

 

I would appreciate any guidance to how to achieve this. Currently I have this formula active:

AVERAGEX(SUMMARIZE(table,table[Case ID]),AVERAGE(table[CSAT])))

 

Below is unpivoted Raw data.
Applicable row needs to be used for category based calculation.

Case IDCategoryApplicable RowCSAT
1Wine17
1Beer17
1Spirit07
1Juice07
1Water07
2Wine09
2Beer09
2Spirit19
2Juice09
2Water09
3Wine13
3Beer13
3Spirit13
3Juice13
3Water13
4Wine15
4Beer05
4Spirit05
4Juice05
4Water15
5Wine110
5Beer010
5Spirit010
5Juice110
5Water010

 

 

Here is the output i need. I am able to get either correct calcualtion for category or for total, but not both ion the same visual (Matrix/table).

Categoryavg CSAT
Beer5
Juice6.5
Spirit6
Water4
Wine6.25
Total6.8
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hey

    Managed to achieve it with this

    Measure = CALCULATE(AVERAGE('Table'[CSAT]),FILTER(SUMMARIZE('Table','Table'[Case ID],"maxi",max('Table'[Applicable Row])),[maxi]=1))
    Thanks all who took the time to look into this!!!

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hey

    Managed to achieve it with this

    Measure = CALCULATE(AVERAGE('Table'[CSAT]),FILTER(SUMMARIZE('Table','Table'[Case ID],"maxi",max('Table'[Applicable Row])),[maxi]=1))
    Thanks all who took the time to look into this!!!
  • Anonymous , Try like

     

     

    AVERAGEX(Values(table[Case ID]),calculate(AVERAGE(table[CSAT])))

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hey amitchandak , thanks for the reply.

      Unfortunatelly, it didnt work.

      Got total in all rows (as below).

       

      Categoryavg CSAT
      Beer6.8
      Juice6.8
      Spirit6.8
      Water6.8
      Wine6.8
      Total6.8