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

issue with if statement inside sum function

Hi All,

I have an if statement inside my sum function that is giving wrong result. For example

sum( if(year(IncidentDate)>= year(MaxIncindentDate) - 2,calltime)) is giving me 515224 while sum(calltime) is giving me 357.7951 value

Please note that the condition inside if statement is supposed to fetch all data as I only have past two years data at the moment and the if statement means to fetch data for last three years including current year. Therefore, logically both statements should give same result. I believe that 357.7951 is the correct value though

Can someone please help me understand the difference here

Arif

5 Replies
luciancotea
Specialist
Specialist

I suppose that IncidentDate, MaxIncidentDate and calltime are not in the same table?

Not applicable
Author

IncidentDate and Calltime are in same table. MaxIncidentDate is a variable i created in load script.

If I had to write the same statement in a set analysis, how will the statement look like?

Arif

luciancotea
Specialist
Specialist

Something like:

=sum({<IncidentDate={">=$(=YearStart(AddYears(MaxIncidentDate, -2)))"}>} calltime)

Not applicable
Author

OK the set analsysi expression is also giving 515224. Then I tried sum( if(1,calltime)) and it is also giving 515224 value. sum(calltime) is giving 357.7951 value though

Not sure whats happening here

Arif

luciancotea
Specialist
Specialist

There's something wrong with your data structure. You must post an example so we can stop guessing.