Forum Discussion

HeihoSilver's avatar
HeihoSilver
Frequent Visitor
2 years ago
Solved

Cummulative Average in Line Chart

Hi,  I need to establishe a line chart where it accumulate the average value of a Days Open vs Month Year for the last 12 complete months. I have many Datasets to connect to but to simplify I need ...
  • HeihoSilver's avatar
    2 years ago

    Hi,
    Thank you for your support. I found the way to plot the line chart correctly from  Youtube Power BI Cumulative Lince Chart. We just need to add ALLSELECTED in the Calculate filter.


     

    CumulAverageDaysOpen_RITMActive = // the formula calculate cumulative Average Days Open for Active RITM for the last 12 complete months. 
    VAR CurrentDate = TODAY()
    VAR LastFullMonthEnd = EOMONTH(CurrentDate, -1) -- End of the last full month
    VAR StartDate = EOMONTH(LastFullMonthEnd, -12) -- Start date, 12 months before the end of the last full month
    
    -- Table with all dates within the range
    VAR DatesInRange = 
        FILTER(
            ALL('DateTable'),
            'DateTable'[Date] > StartDate &&
            'DateTable'[Date] <= LastFullMonthEnd
        )
    
    -- Cumulative average calculation
    RETURN
    AVERAGEX(
        FILTER(
            DatesInRange,
            'DateTable'[Date] <= MAX('DateTable'[Date])
        ),
        CALCULATE(
            AVERAGE('Active RITM Delivery Time'[Days Open]),
            ALLSELECTED('Active RITM Delivery Time'), 
            'Active RITM Delivery Time'[Created] <= MAX('DateTable'[Date])
        )
    )

     

     

    Month-YearDays OpenCumulative Average
    Jul-23352352
    Aug-23(352 + 337 + 330 + 316) / 4337.75
    Sep-23(352 + 337 + 330 + 316) / 4337.75
    Oct-23(352 + 337 + 330 + 316 + 260 + 255) / 6308.33
    Nov-23(352 + 337 + 330 + 316 + 260 + 255 + 226 + 218 + 218) / 9279.11
    Dec-23(352 + 337 + 330 + 316 + 260 + 255 + 226 + 218 + 218 + 198) / 10 271