Forum Discussion

nanacobsbs's avatar
nanacobsbs
Helper I
1 year ago

Average Dax

 

The matrix is shown in Fig and Dax Dommand is bellow.

Average = AVERAGE('Test'[Nov])

I would like to display the averaged results on each row, what DAX should I use?
I want the total row to have the same value as the maximum of the selected DATE numbers.

12 Replies

  • nanacobsbs , Try using

     

    DAX
    Average =
    IF(
    HASONEVALUE('Test'[DATE]),
    AVERAGE('Test'[Nov]),
    MAXX(ALL('Test'[DATE]), 'Test'[Nov])
    )

    • nanacobsbs's avatar
      nanacobsbs
      Helper I

      Thank you, but it does't work.

      I would like to get the following calculation results.
      Is it possible?

       

       

      • bhanu_gautam's avatar
        bhanu_gautam
        Super User

        nanacobsbs Try this one

         

        RunningAverage =
        IF(
        HASONEVALUE('Test'[DATE]),
        CALCULATE(
        AVERAGEX(
        FILTER(
        ALL('Test'[DATE]),
        'Test'[DATE] <= MAX('Test'[DATE])
        ),
        'Test'[Nov]
        )
        ),
        CALCULATE(
        AVERAGEX(
        ALL('Test'[DATE]),
        'Test'[Nov]
        )
        )
        )

  • Ray_Minds's avatar
    Ray_Minds
    Solution Supplier

    nanacobsbs  Please find the solution :

    Average Unit Price =

    Average :=
    IF (
        HASONEVALUE ( 'Test'[Date] ),
        AVERAGE ( 'Test'[Nov] ),
        CALCULATE (
            AVERAGE ( 'Test'[Nov] ),
            'Test'[Date] = MAX ( 'Test'[Date] )
        )
    )