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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
narender123
Specialist
Specialist

how to write expression in script

Hi

I want to set an expression in script.

=if(GetSelectedCount(Import)=0,sum({<Year={$(=max(Year))},STATUS_CODE={350,360},REGIME={'C*'},Export=,TAXCODE={'ED'}>}TAX),sum({<Year={$(=max(Year))},STATUS_CODE={350,360},Export=,TAXCODE={'ED'}>}TAX))

I have written this expression in chart expression using set analysis .Now i want it to write in Script level.How to write it???

Thanks

10 Replies
narender123
Specialist
Specialist
Author

Could you please give me some suggestion to write this expression in script??

sum({<Year={STATUS_CODE={350,360},REGIME={'C*'},Export=,TAXCODE={'ED'}>}TAX)


er_mohit
Master II
Master II

Try this

if(widmatch(STATUS_CODE,'350','360') or match(REGIME,'C*') or TAXCODE='ED',TAX) as TAX

hope it helps

Edited by Me:--

Sorry by mistake i write Or condition

if(widmatch(STATUS_CODE,'350','360') and match(REGIME,'C*') and TAXCODE='ED',TAX) as TAX


here you don't want to mention the sum simply in your expression used Sum(TAX) because your subtotal works on the basis of sum(fieldname)

your TAX field value is just like in expression sum(TAX) if you want total then put sum in expression then it gives the overall total which you get in expression like this way

sum(total TAX)

hope it helps


narender123
Specialist
Specialist
Author

I dont understand with your or conditions as in my expression there is and condition .

So Please tell me

Thanks.

Not applicable

Hi,

How about:

if( (STATUS_CODE='350' or STATUS_CODE='360') and left(REGIME,1)='C' and TAXCODE='ED', TAX) as TAX

Regards,

Lester

narender123
Specialist
Specialist
Author

Hi Lester,

But there is no sum condition.

Thanks

jagan
Partner - Champion III
Partner - Champion III

Hi Narendar,

Use Sum(TAX) in your expression or else calculate the sum in Load script by using

Tax:

LOAD

     Sum(TAX) AS TotalTax

FROM TableName;

Hope this helps you.

Regards,

Jagan.

narender123
Specialist
Specialist
Author

Hi Mohit,

Thanks for your reply.

But its not working. see the attached file.

narender123
Specialist
Specialist
Author

Hi Jagan,

Thanks for your reply

could yopu please give the solution of whole expression in script means how to write it on script level.

sum({<Year={STATUS_CODE={350,360},REGIME={'C*'},Export=,TAXCODE={'ED'}>}TAX)


jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

Table1:

LOAD

     *,

     If((STATUS_CODE= 350 OR STATUS_CODE= 360) AND LEFT(REGIME)='C' AND TAXCODE='ED', TAX, 0) AS           CalculatedTax

FROM DataSource;

Tax:

LOAD

     Sum(TAX) AS TotalTax

FROM Table1;

Now you can just use TotalTax in your expression.

Hope this helps you.

Regards,

Jagan.