Forum Discussion

Tevon713's avatar
Tevon713
Helper V
4 years ago
Solved

Calculating row average within matrix

Hi.   I'm trying to find average of a row within a matrix. Might be a simple solution, I may be overthinking it.   Got a simple table with the following variables.   When creating the mat...
  • v-kelly-msft's avatar
    v-kelly-msft
    4 years ago

    Hi  Tevon713 ,

     

    Create a measure as below:

    Measure =
    VAR _month =
        ISINSCOPE ( 'Table'[Month] )
    VAR _site =
        ISINSCOPE ( 'Table'[Site] )
    VAR _region =
        ISINSCOPE ( 'Table'[Region] )
    VAR _year =
        ISINSCOPE ( 'Table'[Year] )
    RETURN
        IF (
            _month,
            SUM ( 'Table'[FTE] ),
            IF (
                _site && NOT ( _month ),
                AVERAGEX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Year] = MAX ( 'Table'[Year] )
                            && 'Table'[Region] = MAX ( 'Table'[Region] )
                            && 'Table'[Site] = MAX ( 'Table'[Site] )
                    ),
                    'Table'[FTE]
                ),
                IF (
                    _region && NOT ( _site ),
                    AVERAGEX (
                        FILTER (
                            ALL ( 'Table' ),
                            'Table'[Year] = MAX ( 'Table'[Year] )
                                && 'Table'[Region] = MAX ( 'Table'[Region] )
                        ),
                        'Table'[FTE]
                    ),
                    IF (
                        _year && NOT ( _region ),
                        AVERAGEX (
                            FILTER ( ALL ( 'Table' ), 'Table'[Year] = MAX ( 'Table'[Year] ) ),
                            'Table'[FTE]
                        )
                    )
                )
            )
        )
    

    And you will see:

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my reply as a solution!