Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
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
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

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
Follow me on my LinkedIn | Know IPC Global at ipc-global.com