Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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

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

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