Forum Discussion

Nathaniel_C's avatar
Nathaniel_C
Community Champion
4 years ago
Solved

Average

Hi All,

This works with a single month selected, but not with multiple months.  Trying to show the average of what shows in the visual, and then color format the column background.

This is my pbix 

  

Thank you!


Nathaniel

 

  • Hi,

    Could you please try the below whether it provides the result that you want?

     

    Average =
    AVERAGEX (
        FILTER (
            ADDCOLUMNS (
                VALUES ( 'DataTable'[Name] ),
                "@ERecsperhour", CALCULATE ( SUM ( 'DataTable'[E-Recs per Hour] ) )
            ),
            [@ERecsperhour] <> 0
        ),
        [@ERecsperhour]
    )
    

     

     

  • Average = AVERAGE('DataTable'[E-Recs per Hour])
    = AVERAGEX('DataTable', 'DataTable'[E-Recs per Hour])

    the calculation of average is based on the rows of 'DataTable' in the current filter context; it has nothing to do with the calculation in the table viz.

     

    AVG = 
    VAR __n = VALUES( 'DataTable'[Name] )
    RETURN
        SUMX( __n, CALCULATE( SUM( 'DataTable'[E-Recs per Hour] ) ) )
            / COUNTROWS( __n )

4 Replies

  • Hi,

    Could you please try the below whether it provides the result that you want?

     

    Average =
    AVERAGEX (
        FILTER (
            ADDCOLUMNS (
                VALUES ( 'DataTable'[Name] ),
                "@ERecsperhour", CALCULATE ( SUM ( 'DataTable'[E-Recs per Hour] ) )
            ),
            [@ERecsperhour] <> 0
        ),
        [@ERecsperhour]
    )
    

     

     

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion
    Average = AVERAGE('DataTable'[E-Recs per Hour])
    = AVERAGEX('DataTable', 'DataTable'[E-Recs per Hour])

    the calculation of average is based on the rows of 'DataTable' in the current filter context; it has nothing to do with the calculation in the table viz.

     

    AVG = 
    VAR __n = VALUES( 'DataTable'[Name] )
    RETURN
        SUMX( __n, CALCULATE( SUM( 'DataTable'[E-Recs per Hour] ) ) )
            / COUNTROWS( __n )

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi Nathaniel_C 
    Here is the sample file with the solutoion https://www.dropbox.com/t/M7zX39R3UdSCO9SR

    You want to calculate the average of the sum. The row level average won't help. Can follow this 

    Average New = 
    AVERAGEX ( 
        VALUES ( 'DataTable'[Name] ),
        CALCULATE ( SUM ( 'DataTable'[E-Recs per Hour] ) )
    )