Forum Discussion

ToKo's avatar
ToKo
Frequent Visitor
6 years ago
Solved

Cumulative line values for chart

Hello,   I would like to build cumulative line value for  below chart.   I have plan for all month for example its 2400min in December I have 18 working days so 2400/18 = 133,33 daily. I w...
  • Anonymous's avatar
    Anonymous
    6 years ago

    HI ToKo ,

    Did your table contain the original amount field? I'd like to suggest you use the following measure formula with original amount fields:

    Measure = 
    VAR currDate =
        MAX ( 'Table'[Date] )
    VAR dateRange =
        CALCULATETABLE (
            VALUES ( 'Table'[Date] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                YEAR ( [Date] ) = YEAR ( currDate )
                    && MONTH ( [Date] ) = MONTH ( currDate )
            )
        )
    VAR total =
        CALCULATE (
            SUM ( 'Table'[Amount] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                YEAR ( [Date] ) = YEAR ( currDate )
                    && MONTH ( [Date] ) = MONTH ( currDate )
            )
        )
    VAR duration =
        DATEDIFF ( MINX ( dateRange, [Date] ), MAXX ( dateRange, [Date] ), DAY )
    RETURN
        total / duration 
            * DATEDIFF ( MINX ( dateRange, [Date] ), currDate, DAY )
    

    Regards,

    Xiaoxin Sheng