Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Sum per month

Hi,    I have the following table:     I would like to get the sum of the values in the graph instead of the values, so for February it should be 7 and for March it would be 9. Any tips her...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Do you have a dedicated Date Table?  If so, you can leverage the builtin time-intelligence functions to give you Total Year to Date of a measure:

     TOTALYTD MEASURE=
    /*-------------------------------------------------------------------------
                'Simple calculation when do not need further complex filtering'
                'Use the Date/Calendar Table and Date Key'
                'Be sure that the Date Table is set as a date table'
    --------------------------------------------------------------------------*/
     TOTALYTD ( [MEASURE] , Date[DateKey] ',Optional Fiscal Year End')

    If you want to use a column, this code will work:

    Cumulative Total Based on Date = 
    VAR __CurrentDate= Table1[Date]
    RETURN
    
    CALCULATE(
        COUNTROWS( Table1 ),
        FILTER(
            ALL( Table1),
            __CurrentDate >= Table1[Date]
        )
    )