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

String Function

Hi all,

I want to calculate the fields based on the following condition.

If the material code ends with 'S' then the quantity should be multiplied by 2 else the quantity remains the same.

I tried the below codition but it results with some syntax error.

if([Material code] like '%s', ([Quantity]*2),[Quantity]) as [Billed Quantity]

Please provide me some solution to make it work

Thanks,

Gaayathri

5 Replies
swuehl
MVP
MVP

Try a string function like right()

if(right([Material code],1)='s', ([Quantity]*2),[Quantity]) as [Billed Quantity]

Not applicable
Author

Hi Swuehl,

Thanks for your spontaneous reply!!!

I have tried your solution, but again i m getting the syntax error..

Can u please suggest some other idea for my condition?

Thanks,

Gaayathri

swuehl
MVP
MVP

Hm, I believe the above approach should work out.

[Material code] and [Quantity] have to be fields from your input table, not renamed fields or originated in another table.

Could you post your complete LOAD script of this table load?

Not applicable
Author

Acctually These are from SAP Tables...

I have copied the fields until the requeired Field.

[VBRP]:

Load

// Key fields:

    [VBELN] as [%BillingDocument_Key],

       [VBELN] & '/' & [POSNR] as [%BillingDocumentItem_Key],

// Additional fields:

    ([NETWR] - [WAVWR]) as [Billing Sales Margin Amount],

    1 as [Billing Item Counter],

// Renamed fields:

    [MATNR] as [Billing Material_MATNR],

    [FKIMG] as [Billing Sales Quantity_FKIMG],

    [NETWR] as [Billing Sales Amount_NETWR],

    [MEINS] as [Billing Base Unit_MEINS],

if(right([MATNR],1)='s', ([FKIMG]*2),[FKIMG]) as [Billed Quantity_FKIMG];

SQL SELECT VBELV POSNV VBELN POSNN

FROM VBFA WHERE (VBTYP_N ='M' OR VBTYP_N ='O') AND (VBTYP_V ='J' OR VBTYP_V ='T');

swuehl
MVP
MVP

Maybe I just don't get something here, but some of the fields you use in your load part are not part of the SQL SELECT, right? I believe this won't work then, you need to get those field from the DB using SQL SELECT first.