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: 
LESSASSY_K
Contributor III
Contributor III

divide in script - always zero as a result

Hello everyone,

 

I have an issue regarding a division in my qlikview app/script

I tried to to that:

ALT(((SUM(FLUX_PIECES_POIDS_PLASTIQUE) * SUM(QTY_ON_HAND))/SUM(SALES_MULTIPLE)),0) as PIECES_POIDS_EMBALLAGE_PLASTIQUE, //Poids emballage pièce plastique
ALT(((SUM(FLUX_PIECES_POIDS_CARTON) * SUM(QTY_ON_HAND))/SUM(SALES_MULTIPLE)),0) as PIECES_POIDS_EMBALLAGE_CARTON, //Poids emballage pièce plastique
ALT(((SUM(FLUX_PIECES_POIDS_BOIS) * SUM(QTY_ON_HAND))/SUM(SALES_MULTIPLE)),0) as PIECES_POIDS_EMBALLAGE_BOIS //Poids emballage pièce plastique

But as a result i always get zero values.

I don't understand what i did wrong.

Of course i used a group by.

Even if i don't use aggregation and group by i get zero as a result from these 3 calculated measure. Anyone could help please.

Thanks

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

Did you try looking at the values individually?

ALT(((SUM(FLUX_PIECES_POIDS_PLASTIQUE) * SUM(QTY_ON_HAND))/SUM(SALES_MULTIPLE)),0) 

SUM(FLUX_PIECES_POIDS_PLASTIQUE) as tmp1,
SUM(QTY_ON_HAND) as tmp2,
SUM(SALES_MULTIPLE) as tmp3,
ALT(((SUM(FLUX_PIECES_POIDS_PLASTIQUE) * SUM(QTY_ON_HAND))/SUM(SALES_MULTIPLE)),0) as PIECES_POIDS_EMBALLAGE_PLASTIQUE

You will get 0 in three scenarios

1) If tmp1 is 0 or
2) if tmp2 is 0 or
3) if tmp3 is 0

Do you see any rows where all three tmp1, tmp2, tmp3 are not 0 at the same time?

View solution in original post

3 Replies
LESSASSY_K
Contributor III
Contributor III
Author

Anyone ???

sunny_talwar

Did you try looking at the values individually?

ALT(((SUM(FLUX_PIECES_POIDS_PLASTIQUE) * SUM(QTY_ON_HAND))/SUM(SALES_MULTIPLE)),0) 

SUM(FLUX_PIECES_POIDS_PLASTIQUE) as tmp1,
SUM(QTY_ON_HAND) as tmp2,
SUM(SALES_MULTIPLE) as tmp3,
ALT(((SUM(FLUX_PIECES_POIDS_PLASTIQUE) * SUM(QTY_ON_HAND))/SUM(SALES_MULTIPLE)),0) as PIECES_POIDS_EMBALLAGE_PLASTIQUE

You will get 0 in three scenarios

1) If tmp1 is 0 or
2) if tmp2 is 0 or
3) if tmp3 is 0

Do you see any rows where all three tmp1, tmp2, tmp3 are not 0 at the same time?

LESSASSY_K
Contributor III
Contributor III
Author

Yes indeed i looked at the valuesindividually and i notice an issue.

It was an issue regarding a left join which wasn't working right that's why i had no values.

Thanks a lot