Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Krzysztof-Wroclawski
Former Employee
Former Employee

"Divide IF" in LOAD script

Hi Experts,

SAMPLE

DATA:

LOAD

Amount,

Amount/NumberOfMonths1*12 as AnnualValue,

//NumberOfMonths1,

date(if(len(trim([NumberOfMonths1]))=0, "NumberOfMonths2", "NumberOfMonths1")) as NumberOfMonths1,

NumberOMonths2

FROM [lib://DATAforDATA.csv]

(txt, utf8, embedded labels, delimiter is ',', msq)

I would like to have AnnualValue field always populated. Sometimes it is not because NumberOfMonths1 is empty. My idea is that if NumberOfMonths1 is empty there will be the backup field called NumberOfMonths2 which can be used in this occasion (this field has fewer data overall but in cases where NumberOfMonths1 is empty, NumberOfMonths2 is always there).

Thank you!

Kris

1 Solution

Accepted Solutions
rubenmarin

Hi Krzystof, Alt() funtion returns the first numeric paremeter it founds, so you can use:

Amount/Alt(NumberOfMonths1,NumberOfMonths2)*12 as AnnualValue,

View solution in original post

2 Replies
rubenmarin

Hi Krzystof, Alt() funtion returns the first numeric paremeter it founds, so you can use:

Amount/Alt(NumberOfMonths1,NumberOfMonths2)*12 as AnnualValue,

Krzysztof-Wroclawski
Former Employee
Former Employee
Author

Thank you Ruben. Perfect solution!