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

Invalid Expression in Script (if)

hi,

Please see what is wrong with my syntax,  This exact formula works on the frontend but doesnt work in the script.  No idea why,

Script below:

RAWTABLE:

Load Ticket Typ,

         RecSite

.......

Load Count([Ticket Typ]) as TotalClaims,

if(mid(RecSite,2,1)='F','Franchise','Corporate') as Type

Resident RAWTABLE;

Formula in question is in bold.

6 Replies
oknotsen
Master III
Master III

Function seems to be fine, though I do get the idea your are missing a "group by" to make that count work.

May you live in interesting times!
Peter_Cammaert
Partner - Champion III
Partner - Champion III

You cannot use a Count() aggregation function and an individual field-that-isn't present-in-a-GROUP-BY clause in the same load. In addition to that, there is no GROUP BY clause. What are you planning to do?

Anonymous
Not applicable
Author

All i need the count for is to do calculations on the frontend (Percentages).  So il just remove the code from the script and add it to the frontend.

oknotsen
Master III
Master III

For that I suggest you do that Type calculation (that IF statement) in your script and do the count in the front-end anyway.

The expression to calculate your percentage will be something like this:

count([Ticket Type]) / count(TOTAL [Ticket Type]

May you live in interesting times!
omkarvamsi
Creator
Creator

1.we need to use Group By in script when we are using aggregating functions like SUM,MIN,MAX,COUNT....

2.in group by we have to use all the dimensions using in the load statement.

3.for example:

    LOAD COUNTRY,

                REGION,

              SUM(POPULATION)

  FROM TABLE.QVD

  GROUP BY COUNTRY,REGION;

Anonymous
Not applicable
Author

Hi

Add Count([Ticket Typ]) in  front end and keep you expression in  script as it is.

If you want to do it in script use by Groupby .

load

if(mid(RecSite,2,1)='F','Franchise','Corporate') as Type

Resident RAWTABLE

;