Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Sum value by date

Any1 know what's wrong with below DAX?

2017Exp = calculate(sum(XeroMasterExport[ActualExp]),XeroMasterExport[Date]=2017)

 

  • Yes you need to use the YEAR function

     

    2017Exp =
    CALCULATE (
        SUM ( XeroMasterExport[ActualExp] ),
        YEAR ( XeroMasterExport[Date] ) = 2017
    )

    HTH! :smileyhappy:

     

    EDIT: Well you may need to use this instead if you are using any slicers that cause the above to give you blank

     

    2017Exp =
    CALCULATE (
        SUM ( XeroMasterExport[ActualExp] ),
        FILTER ( ALL ( XeroMasterExport ), YEAR ( XeroMasterExport[Date] ) = 2017 )
    )

2 Replies

  • Sean's avatar
    Sean
    Community Champion

    Yes you need to use the YEAR function

     

    2017Exp =
    CALCULATE (
        SUM ( XeroMasterExport[ActualExp] ),
        YEAR ( XeroMasterExport[Date] ) = 2017
    )

    HTH! :smileyhappy:

     

    EDIT: Well you may need to use this instead if you are using any slicers that cause the above to give you blank

     

    2017Exp =
    CALCULATE (
        SUM ( XeroMasterExport[ActualExp] ),
        FILTER ( ALL ( XeroMasterExport ), YEAR ( XeroMasterExport[Date] ) = 2017 )
    )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Seanworked, easy, i love this place!!  thanks!