Forum Discussion

ivannye's avatar
ivannye
Helper I
5 years ago
Solved

calculation error data sumx

Hello,

 

Thank you for your help. 

 

I have an issue where I have the following dax. 

 

Running12months 1 =
var currentdate=SELECTEDVALUE(HeadCount[EndOfMonth])
var yr= YEAR(currentdate)-1
var mt = MONTH(currentdate)+1
var previousdate=DATE(YEAR(currentdate)-1,MONTH(currentdate),DAY(currentdate))
return
SUMX(FILTER(ALLSELECTED(HeadCount[EndOfMonth],HeadCount[Costcentre]),HeadCount[EndOfMonth]>=previousdate && HeadCount[EndOfMonth]<=currentdate),[Empoyees That Left 2])
 
I have the following error

Can you help me please

  • ivannye , Check the datatype of EndOfMonth, That can cause this issue. Over all formula seems correct, Try this small change

     

    Running12months 1 =
    var currentdate=maxx(allselected(HeadCount),[EndOfMonth])
    var yr= YEAR(currentdate)-1
    var mt = MONTH(currentdate)+1
    var previousdate=DATE(YEAR(currentdate)-1,MONTH(currentdate),DAY(currentdate))
    return
    SUMX(FILTER(ALLSELECTED(HeadCount[EndOfMonth],HeadCount[Costcentre]),HeadCount[EndOfMonth]>=previousdate && HeadCount[EndOfMonth]<=currentdate),[Empoyees That Left 2])

3 Replies

  • ivannye , Check the datatype of EndOfMonth, That can cause this issue. Over all formula seems correct, Try this small change

     

    Running12months 1 =
    var currentdate=maxx(allselected(HeadCount),[EndOfMonth])
    var yr= YEAR(currentdate)-1
    var mt = MONTH(currentdate)+1
    var previousdate=DATE(YEAR(currentdate)-1,MONTH(currentdate),DAY(currentdate))
    return
    SUMX(FILTER(ALLSELECTED(HeadCount[EndOfMonth],HeadCount[Costcentre]),HeadCount[EndOfMonth]>=previousdate && HeadCount[EndOfMonth]<=currentdate),[Empoyees That Left 2])

  • I have an issue now to that calculation. 

    The column returns the same number