Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ivannye
Helper I
Helper I

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
ivannye_0-1624947964891.png

Can you help me please

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@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])

View solution in original post

3 REPLIES 3
ivannye
Helper I
Helper I

I have an issue now to that calculation. 

ivannye_0-1624961197849.png

The column returns the same number

 

ivannye
Helper I
Helper I

Worked like a charm. Thank you

amitchandak
Super User
Super User

@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])

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.