Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

Sum with IF condition

Hi experts

I have the following issue:

Detecting the records with a time difference of less than 180 days:

if(interval([Termination Date]-[Contractual Start Date], 'd')<180, 1,0)

The above IF condition must be implemented in this SUM expression, any ideas?

sum(
{<[YearMonth]={"$(='>=' & Monthstart(Addmonths(Max(YearMonth),-11)) & '<=' & MonthEnd(Max(YearMonth)))"}>}
Joiner)

Many thanks, Tom

1 Solution

Accepted Solutions
marksouzacosta
Partner - Specialist
Partner - Specialist

Hi Tom,

I have a personal rule that helps me a lot: if a Measure Expression looks too complex, maybe it is time to revisit your Load Script.
So, can you move the if(interval([Termination Date]-[Contractual Start Date], 'd')<180, 1,0) expression to your Load Script as a field - like [LessThan180Flag]? This will make your Measure way easier to do:

Sum({<[LessThan180Flag]={1}>} Joiner)

Read more at Data Voyagers - datavoyagers.net

View solution in original post

1 Reply
marksouzacosta
Partner - Specialist
Partner - Specialist

Hi Tom,

I have a personal rule that helps me a lot: if a Measure Expression looks too complex, maybe it is time to revisit your Load Script.
So, can you move the if(interval([Termination Date]-[Contractual Start Date], 'd')<180, 1,0) expression to your Load Script as a field - like [LessThan180Flag]? This will make your Measure way easier to do:

Sum({<[LessThan180Flag]={1}>} Joiner)

Read more at Data Voyagers - datavoyagers.net