Forum Discussion
Issues with Calculate sum and getting infinity
- 2 years ago
Hello,
Thank you sevenhills and gmsamborn for your comments.
I figured it out with some manipulation. First i was referencing the wrong table in my code, so that solved most of it. But the comment on using all for the filter helped when i changed my calculated column to a measure.
The revised code for a measure would be:Schedule Hours = VAR Currentdate = 'Test Hours'[Period End Date] VAR HrsP1 = CALCULATE( SUM('Schedule'[Hrs per Period]), 'Schedule'[No of Periods] = 1, 'Schedule'[End Period] = Currentdate ) VAR HrsP2 = CALCULATE( SUM('Schedule'[Hrs per Period]), FILTER(ALL('Schedule'), 'Schedule'[No of Periods] > 1), FILTER(ALL('Schedule'), 'Schedule'[End Period] - (14*('Schedule'[No of Periods]-1)) <= Currentdate) ) RETURN HrsP1 + HrsP2Thank you to both.
I just want to add, if anyone else has similar issues with infinity, i think it's either incorrect reference or issues with relationships which causes a non stopping loop. That's what i found so far.
Hello,
Thank you sevenhills and gmsamborn for your comments.
I figured it out with some manipulation. First i was referencing the wrong table in my code, so that solved most of it. But the comment on using all for the filter helped when i changed my calculated column to a measure.
The revised code for a measure would be:
Schedule Hours =
VAR Currentdate = 'Test Hours'[Period End Date]
VAR HrsP1 = CALCULATE(
SUM('Schedule'[Hrs per Period]),
'Schedule'[No of Periods] = 1,
'Schedule'[End Period] = Currentdate
)
VAR HrsP2 = CALCULATE(
SUM('Schedule'[Hrs per Period]),
FILTER(ALL('Schedule'), 'Schedule'[No of Periods] > 1),
FILTER(ALL('Schedule'), 'Schedule'[End Period] - (14*('Schedule'[No of Periods]-1)) <= Currentdate)
)
RETURN
HrsP1 + HrsP2
Thank you to both.
I just want to add, if anyone else has similar issues with infinity, i think it's either incorrect reference or issues with relationships which causes a non stopping loop. That's what i found so far.
- sevenhills2 years ago
Super User
glad to hear ALL helped. could you update the above reply with the correct DAX, so that it helps for anyone who checks this post in future!