Forum Discussion

SebaSpotti's avatar
SebaSpotti
Icon for Advocate II rankAdvocate II
1 year ago
Solved

Weight Rolling Averages

Hi all! I have 6 rolling averages calculate each in this way: Rolling AVG 1 = VAR CurrentDate = SELECTEDVALUE(Month[DateMonth]) VAR PreviousDate = DATE(year(CurrentDate),month(CurrentDate)-12,day...
  • SebaSpotti's avatar
    SebaSpotti
    1 year ago

    I think I find an easy solution: 

    WeightedAvgOfRollingAverages = 
    DIVIDE(
        SUMX(
            {
                [Rolling AVG Table1] * DISTINCTCOUNT(Table1[ID]),
                [Rolling AVG Table2] * DISTINCTCOUNT(Table2[ID]),
                [Rolling AVG Table3] * DISTINCTCOUNT(Table3[ID]),
                [Rolling AVG Table4] * DISTINCTCOUNT(Table4[ID]),
                [Rolling AVG Table5] * DISTINCTCOUNT(Table5[ID]),
                [Rolling AVG Table6] * DISTINCTCOUNT(Table6[ID])
            },
            [Value]
        ),
        [TotalWeights]
    )

    where TotalWeights is simply a new measure:

    TotalWeights = DISTINCTCOUNT(Table1[ID])+DISTINCTCOUNT(Table2[ID])+...+DISTINCTCOUNT(Table6[ID])

    It seems working!