Forum Discussion

vrv's avatar
vrv
Icon for Helper II rankHelper II
3 years ago
Solved

DAX expression for yearly total

hello all,

how do I write a DAX expression that is equivalent to the following SQL statement:

select YEAR(myDATE), SUM(myAMOUNT)
from myTABLE
group by YEAR(myDATE)
order by YEAR(myDATE)

 

The result is the sum of myAMOUNT by Year:

Year   myAMOUNT

2019  120 

2020  150 

2021  110 

2022  160

 

Thanks,

vrv

  • Hello vrv ,

     

    so what you need is a dax measure that sums the amount 

    Myamount = sum(tablename[myamount])

     

    then you display this measure alongside with the year dimension and you would be able to see the values as you want.

     

    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

    Follow me on Linkedin

  • vrv's avatar
    vrv
    3 years ago

    Idrisshatila,

    thank you for your reply.

    If I were to need the sum of Amount of only some records that have some flag field set on 1, how would the DAX expression change?

2 Replies

  • Hello vrv ,

     

    so what you need is a dax measure that sums the amount 

    Myamount = sum(tablename[myamount])

     

    then you display this measure alongside with the year dimension and you would be able to see the values as you want.

     

    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

    Follow me on Linkedin

    • vrv's avatar
      vrv
      Icon for Helper II rankHelper II

      Idrisshatila,

      thank you for your reply.

      If I were to need the sum of Amount of only some records that have some flag field set on 1, how would the DAX expression change?