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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.