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: 
Not applicable

error in script with if or set analysis

Hi Friends,

i have a problem with a formula.

If I use

sum({$<OC = {'Z100'}, SM = {'10'} , Linea_P -={'35'}>} F_Imp)

in a field of table it's run

but if I use the formula:

LOAD * ,

sum({$<OC = {'Z100'}, SM = {'10'} , Linea_P -={'35'}>} F_K3) as F_Imp_Avv

FROM $(vQVDDir)\COPA.QVD

(qvd);

or

LOAD * ,

{$<OC = {'Z100'}, SM = {'10'} , Linea_P -={'35'}>} F_K3 as F_Imp_Avv

FROM $(vQVDDir)\COPA.QVD

(qvd);

in the script it don't work.

I Tried with:

sum(if (OC = 'Z100' and SM = '10' and Linea_P <> '35', F_Imp ))

but don't work too.

Can you help me??

thanks a lot

1 Solution

Accepted Solutions
Not applicable
Author

Set analysis don't work in Script.

sum(if (OC = 'Z100' and SM = '10' and Linea_P <> '35', F_Imp ))

group by <all the fields u r using in the table.>

This should work correctly.

May be u r missing "group by " clause while loading the table.

View solution in original post

4 Replies
Not applicable
Author

Hey you would need to do the group by.

Something like below:

Cheers.

Test:

LOAD * INLINE [

    Country, City, Sales, Year

    Australia, Melbourne, 500, 2008

    Canada, Toronto, 900, 2008

    India, Mumbai, 1600, 2008

    India, Chennai, 2500, 2008

    Australia, Melbourne, 700, 2009

    Canada, Toronto, 800, 2009

    India, Mumbai, 2000, 2009

    India, Chennai, 3000, 2009

];

Test2:

load

    sum(if(Year<>2008 and City='Mumbai',Sales)) as NewSales,

    sum(if(Year=2009 and City<>'Chennai'and City <>'Mumbai',Sales)) as NewSales2

    Resident Test

    group by Country,City;

gussfish
Creator II
Creator II

Hi,

my reading of the Reference Manual is that the script language doesn't actually support set expressions - these are only discussed in the RM in the context of chart expressions.  This issue threw me just last week, too!  Hence, in the script you'll need to take advantage of the if() function and the WHERE clause in your load statements.

Angus.

Not applicable
Author

Set analysis don't work in Script.

sum(if (OC = 'Z100' and SM = '10' and Linea_P <> '35', F_Imp ))

group by <all the fields u r using in the table.>

This should work correctly.

May be u r missing "group by " clause while loading the table.

Not applicable
Author

it's ok

thanks a lot

gda