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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.