Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
anitamanders
Contributor II
Contributor II

formula in pivottable based on subtotal

Hello,

hope one of you can help me with this

I have a pivot table with

articlecode          current stock          sales/month

1341012S               `18                              43

                                                                      28

                                                                      41

         subtotal                                            112

What i want is that current stock turns red if the average sales for 3 months (when you select 3 months) is more than current stock

so: sum(sales)/3 > stock  than RED

I have enclosed my document

Example code 1341012S

Current stock =18

avv. for month july/aug/sept = 37,3333  (=112/3)

stock should turn red, but it isn't

when you only select month june (where sales is >18) than it is working, so it seems my formula only looks at the sales and not at subtotal sales

Can someone help me??

Thanks

1 Solution

Accepted Solutions
Not applicable

Hello,

  please find attached the modified version of your document. I have added a table and solved your problem.

I have changed this "=if (sum(aantgelev)/3>(voorraad),red(200),green(200))" with "=if (sum(Total aantgelev)/3>(voorraad),red(200),green(200))". In your example you need the keyword Total to consider all the Sales.

I have also added a new table with a dynamical formula so you can select 1 or n months and you will always have the correct average of Sales.

Hope it's useful.

Regards,

Daniele

View solution in original post

13 Replies
atafsson
Creator
Creator

Hi,

I dont really understand what the fields in your example stands for, but look at the tab 'Visual Cues' in the properties for the table-object.

You can put an expression to compare two different columns against each other.

Skärmklipp.PNG

Hope it helps!

/Axel

Not applicable

Hello,

  please find attached the modified version of your document. I have added a table and solved your problem.

I have changed this "=if (sum(aantgelev)/3>(voorraad),red(200),green(200))" with "=if (sum(Total aantgelev)/3>(voorraad),red(200),green(200))". In your example you need the keyword Total to consider all the Sales.

I have also added a new table with a dynamical formula so you can select 1 or n months and you will always have the correct average of Sales.

Hope it's useful.

Regards,

Daniele

anitamanders
Contributor II
Contributor II
Author

Thanks Daniele,

that was what I was looking for

The dynamical formula works perfect!!

Thank you all for swift replies!!

Not applicable

Hello Anita,

  I'm glad you have found useful the solution!

Regards,

Daniele

anitamanders
Contributor II
Contributor II
Author

Hi Daniele,

one more question maybe you can help me again...

articles with stock = 0 do not turn red, why is that???

eg. code 7194000

As if QV reads 0 not as a number?

I have tried num#(voorraad), but this does not work

Can you help our??

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

For that code(7194000) stock is null.

The value(0,000) shown to you is Null symbol you have mentioned in the Presentation tab.

So you have to use Alt function for this situation

use

Alt(voorrad,0) instead of voorraad or Num#(voorraad)

Hope it helps

anitamanders
Contributor II
Contributor II
Author

no, this doesn't  work

do I use it in the script or in the table (tried both, but maybe not corect...?)

CELAMBARASAN
Partner - Champion
Partner - Champion

Did you used this in backround expression?

anitamanders
Contributor II
Contributor II
Author

yes, but did not work