Forum Discussion

VictorR's avatar
VictorR
Frequent Visitor
7 years ago
Solved

Rolling average with varying conditions

Hi   I have some sample data as I cannot share my actual data:   A table of visits by 6x different people from 3x different companies with their performance.   I am trying to display a visual s...
  • v-frfei-msft's avatar
    7 years ago

    Hi VictorR,

     

    Please check the following steps.

     

    1. Create a dimtime table and create relationship between fact table and date table.

    dimtime = CALENDARAUTO()

    2. Create the measures as below.

     

    latest performance = var maxdate = CALCULATE(MAX(Table1[Date]),ALLSELECTED(Table1))
    return 
    CALCULATE(MAX(Table1[Performance]),FILTER(Table1,Table1[Date]=maxdate))
    
    average performance = AVERAGEX(
    TOPN(6,Table1,Table1[Date],ASC),Table1[Performance])
    Company's Average performance = CALCULATE(SUM(Table1[Performance]),DATEADD(dimtime[Date],-3,MONTH))/CALCULATE(COUNTROWS(Table1),DATEADD(dimtime[Date],-3,MONTH))

     

    For more details, please check the pbix as attached.

     

    Regards,

    Frank