Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Measure: return the max average(by months)

Hi, I've started with Power BI a week ago. I found that was the perfect tool for what i was asked for. I've been chosen to get the time measures of the processes of my company. The metric chosen ha...
  • smpa01's avatar
    4 years ago

    Anonymous  can you try the above?

     

     

     

     

    avgByProdMaxYear = 
    CALCULATE (
        AVERAGE ( 'Sample'[LT] ),
        VAR _base =
            GROUPBY (
                'Sample',
                'Sample'[Product],
                'Sample'[Year],
                "avg", AVERAGEX ( CURRENTGROUP (), 'Sample'[LT] )
            )
        VAR _rank =
            SUMMARIZE (
                FILTER (
                    ADDCOLUMNS (
                        _base,
                        "rank", RANKX ( FILTER ( _base, [Product] = EARLIER ( [Product] ) ), [avg],, DESC )
                    ),
                    [rank] = 1
                ),
                'Sample'[Product],
                'Sample'[Year]
            )
        RETURN
            _rank
    )

     

     

  • smpa01's avatar
    smpa01
    4 years ago

    Anonymous please refer to the attached pbix