Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
brunopaulo
Partner - Creator II
Partner - Creator II

Subtraction of 2 rows depending a 3rd row (Script)

Hi community,

I have something like this. 

Product   TypeProd   A      B

1               7145     1000   0
2               7289     0          2000
3               4888     2500    0
4               7265     3200    0
5               1477     0          500
6               3655     1000    0
7               1788     1500    0

So, i want sum(A) - Sum(B) but only when TypeProd start with 71 or 72 and i want to do this in script. Any ideas?


Thanks in advance

Best Regards

Bruno Paulo

1 Solution

Accepted Solutions
sunny_talwar

May be this

LOAD Product,

     TypeProd,

     A,

     B,

     If(WildMatch(TypeProd, '71*', '72*'), A-B) as NewColumn

From ....

View solution in original post

6 Replies
sunny_talwar

May be this

LOAD Product,

     TypeProd,

     A,

     B,

     If(WildMatch(TypeProd, '71*', '72*'), A-B) as NewColumn

From ....

brunopaulo
Partner - Creator II
Partner - Creator II
Author

I have Time (Year and Month) as dimension it appear some results without time associated and negative values. (it shouldnt happen).

Any other idea?

vkish16161
Creator III
Creator III

If(WildMatch(TypeProd, "71*", "72*"), A-B) as NewColumn


- Double quotes should do the trick. Let us know if it doesn't work.

brunopaulo
Partner - Creator II
Partner - Creator II
Author

I guess Sunny Solutions is almost rigth in terms of values, but it creats 1 bar without time associated and i can't get it why. The double quotes didn't work.

sunny_talwar

Without time? Where is Time coming from? May you need to check 'Suppress Zero Value' on presentation tab?

brunopaulo
Partner - Creator II
Partner - Creator II
Author

Yes, supress Zero Value solved the issue. Thank you Sunny, perfect as always. Regards