Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Create Negative Value in Script

Hi, I am still learning Qlikview and am trying to make sense of the script that our developer created.  When we have a Credit transaction, the dollar value is listed as a negative in reports I create (that part of our script is working), however if I want to calculate units it is counting the Credit as a positive number and throwing our total unit count off.  I need the Flag below to count the credits as a negative, but still make them visible in a report showing the value as "-1", or whatever the true count would be.  Right now, it shows all of our items in a transaction report as a unit of "1",  even though there are several credits in the report.

Here is the section in my script that sets the Revenue Flag, with CR being the Credit:

LOAD

*,

IF(Tran_CTranType='CR','1',

   IF(Tran_CTranType='S','1',

     IF(Tran_CTranType='SC','1',

      IF(Tran_CTranType='RI','1',

       IF(Tran_CTranType='RR','1'))))) AS Revenue_Flag;

I'd appreciate any help.  Thanks!

1 Solution

Accepted Solutions
Not applicable

Re: Create Negative Value in Script

You could try it like this sample.

5 Replies
Not applicable

Re: Create Negative Value in Script

Hi,

you will need to generate the flag in the script as negative for the credit transaction and then you will have to use that flag in your reports as well. I hope you are already doing it in your reports. so you just need to modify your script to make the flag negative when the transaction type is CR. try using below code.

LOAD

*,

IF(Tran_CTranType='CR','-1',

   IF(Tran_CTranType='S','1',

     IF(Tran_CTranType='SC','1',

      IF(Tran_CTranType='RI','1',

       IF(Tran_CTranType='RR','1'))))) AS Revenue_Flag;

may be this will help you.

Thanks & Best Regards,

Kuldeep Tak

Not applicable

Re: Create Negative Value in Script

Thank you for your quick reply!  I had tried that before and it still wasn't showing the transaction items as -1 in the report.  I have edited the script again to the -1, and here is the expression I'm using to sum the units:

SUM({<Revenue_Flag={'-1','1'}>} TranItem_Quantity)

When I look at the items listed in the report filtered down to Credits only, I see the units at "1" instead of "-1", but the dollar amounts are in parentheses to indicate a negative amount.

Is there something else I should be doing in my expression?  I am trying my best to figure this out on my own, but I am really stuck on this one (and it's probably an easy fix!) 

Thanks for the help!

Not applicable

Re: Create Negative Value in Script

You could try it like this sample.

Not applicable

Re: Create Negative Value in Script

Thank you!  That did it.  I figured it was an easy solution, I'm just not so good with expressions yet! 

Not applicable

Re: Create Negative Value in Script

Hi,

Try using this

SUM({<Revenue_Flag={'-1','1'}>} TranItem_Quantity*Revenue_Flag)

Thanks & Best Regards,

Kuldeep Tak