Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
christophebrault
Specialist
Specialist

Calcul rules

Hi

I explain my situation :

i have 3 industry doing products with differents speed :

                           Products quantity               Speed (product / hour)

Industry1                 100                                  5

Industry2                 200                                 10

Industry3                 300                                  15

in a chart, i want to show the total production time for all my industry ( 1 + 2 + 3 )

In my expression, i do sum(products quantity) / Sum(Speed) BUT its not working.

Qlik view do (100 + 200 + 300) / (5 + 10 + 15)

how can i do (100*5)+ (200*10) + (300*15)

Thanks for your help

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
1 Solution

Accepted Solutions
johnw
Champion III
Champion III

If the chart you show is your raw data:

sum("Products quantity" * "Speed (product/hour)")

If your products quantity and speed columns are sums by industry in the chart, and you're trying to get a total line:

sum(aggr(sum("Products quantity")*sum("Speed (product/hour)"),"Industry"))

Or are you trying to do a weighted average?

sum("Products quantity" * "Speed (product/hour)")/sum("Speed (product/hour)")


sum(aggr(sum("Products quantity")*sum("Speed (product/hour)"),"Industry"))/sum("Speed (product/hour)")

View solution in original post

6 Replies
Sokkorn
Master
Master

Hi

Try this sum(TOTAL products quantity) / Sum(TOTAL Speed)

(100*5)+ (200*10) + (300*15) ==> [Products quantity] * [Speed (product / hour)]

Regards,

Sokkorn Cheav

Not applicable

try using set analysis:

(sum({<Industry={'Industry1'}>} [products quantity])/sum({<Industry={'Industry1'}>}Speed))

+

(sum({<Industry={'Industry2'}>} [products quantity])/sum({<Industry={'Industry2'}>}Speed))

+

(sum({<Industry={'Industry3'}>} [products quantity])/sum({<Industry={'Industry3'}>}Speed))

christophebrault
Specialist
Specialist
Author

[Products quantity] * [Speed (product / hour)] don't work, it returns  -  ...

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
christophebrault
Specialist
Specialist
Author

ok, but i have a listbox to make selection between differents industries. I i use this  set analysis, i can't have a dynamic selection on industries.

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
Not applicable

Ok if in the chart you use industry as a dimension then sum(products quantity) / Sum(Speed) should work because it is only applying it to each Industry at a time.

I am not sure if it will work but you could try using an IF THEN statement instead:

(sum(If(Industry='Industry1', [products quantity],0))/sum(if(Industry='Industry1',Speed,0)))

+

(sum(If(Industry='Industry2', [products quantity],0))/sum(if(Industry='Industry2',Speed,0)))


+

(sum(If(Industry='Industry3', [products quantity],0))/sum(if(Industry='Industry3',Speed,0)))

johnw
Champion III
Champion III

If the chart you show is your raw data:

sum("Products quantity" * "Speed (product/hour)")

If your products quantity and speed columns are sums by industry in the chart, and you're trying to get a total line:

sum(aggr(sum("Products quantity")*sum("Speed (product/hour)"),"Industry"))

Or are you trying to do a weighted average?

sum("Products quantity" * "Speed (product/hour)")/sum("Speed (product/hour)")


sum(aggr(sum("Products quantity")*sum("Speed (product/hour)"),"Industry"))/sum("Speed (product/hour)")