Forum Discussion

4 Replies

  • Nathaniel_C's avatar
    Nathaniel_C
    Community Champion

    Hi Nobie ,
    If I understand your question, please try this:

    Average Per Category = 
    
    var _category = MAX(Prod[Category])
    
    var _calc = CALCULATE(AVERAGEX(Prod,Prod[Price]*Prod[Quantity]),FILTER(ALL(Prod),Prod[Category]=_category))
    
    return _calc

    On your measure for average, isn't that the total?

    Let me know if you have any questions.

    If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πŸ‘are nice too.
    Nathaniel

     



    • Nathaniel_C's avatar
      Nathaniel_C
      Community Champion

      Hi Nobie ,
      If you want to only place that value 1x for each category, you might wish to try this:

      Average Per Category Clean = 
      
      var _category = MAX(Prod[Category])
      
      var _product = MAX(Prod[Product])
      
      var _calc = CALCULATE(AVERAGEX(Prod,Prod[Price]*Prod[Quantity]),FILTER(ALL(Prod),Prod[Category]=_category))
      
      var _calcMax = CALCULATE(MAX(Prod[Product]), FILTER(ALL(Prod),Prod[Category]=_category))
      
      
      return IF(_product = _calcMax,_calc)

       


      Let me know if you have any questions.

      If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πŸ‘are nice too.
      Nathaniel

    • Nobie's avatar
      Nobie
      Helper II

      Hi Nathaniel_C , Thanks for a solution
      but this is not the solution I am looking.
      U can see your solution is giving me an average for a category but I need the sum of the average.
      in place of 804 it should be sum of 791+800+821 =1673.

       

      • Nathaniel_C's avatar
        Nathaniel_C
        Community Champion

        Hi Nobie ,
        Please try this:

        Sum of Avg = 
        
        var _category = MAX(Prod[Category])
        Var _product = MAX(Prod[Product])
        var _maxProd = CALCULATE(MAX(Prod[Product]), FILTER(ALL(Prod),Prod[Category]= _category))
        
        var _Table = SUMMARIZECOLUMNS(Prod[Category],"zzzz",Sumx(Prod,Prod[Price]*Prod[Quantity]))
        
        
        
        var _calc = CALCULATE(MAX('Table'[zzzz]),'Table'[Category]=_category)
        
        
        return IF(_maxProd=_product,_calc)


        Let me know if you have any questions.

        If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πŸ‘are nice too.
        Nathaniel