Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Share your agentic AI experience, learn from others, and earn a new badge: Put Agentic AI to Work
cancel
Showing results for 
Search instead for 
Did you mean: 
JesusAlv4
Contributor III
Contributor III

Percentage operation between two expressions

Regards,

I have the following: In a simple table with 3 dimensions and 3 expressions,The three dimensions are values of Technology, Area and product.The three expressions are the goal to produce, PRODGOAL = I use an (if) to not add the zero values. PRODUCED = The sum of what is produced per day. PERCENT = division between (PRODUCED / PRODGOAL)
The calculation is done well, but having the total of the column, this result does not add up, it is not expected.

5940/7112 = 63% this bad must be 83%

If PRODGOAL (Produced = 0, 0, sum (PRODGOALS))

PRODUCED = Sum (QTYGOOD)

PERCENT = (Produced / PRODGOAL)

Percent.jpg

Labels (2)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

Try this

PRODUCIDO/
Sum(Aggr(
    If(Sum(QTYGOOD) = 0, 0, Sum(PRODGOALS))
, XnAreaDes.., WRKCTRID, ITEMID))

From the image, I couldn't determine the name of your first dimension, but you need to use that within the Aggr() function. 

View solution in original post

8 Replies
Sue_Macaluso
Former Employee
Former Employee

@JesusAlv4  Are you using QlikView or Qlik Sense? I would like to move this into the correct product forum. 

Did you find a solution to your question? Mark the solution as accepted : and if you found it useful, press the like button!
JesusAlv4
Contributor III
Contributor III
Author

Sorry Sue,  it is a Qlikview product, and change the label to the correct forum, thanks.

sunny_talwar
MVP
MVP

What exactly are your expressions for the three columns? Are you using column reference for PRODGOAL expression?

JesusAlv4
Contributor III
Contributor III
Author

Hello Sunny,

 

With IF sentence, I change the value to ZERO, so that it does not add up to the total production goal.

 

If (PRODUCIDO = 0, 0, Sum(PRODGOALS))

Percent01.jpg

when I remove those rows of ZERO the calculation of percentage is not correct

example  image,  2337/1778 =  correct percent  131%   not 99%

Percent02.jpg

sunny_talwar
MVP
MVP

What is your expression for PRODUCIDO column?

JesusAlv4
Contributor III
Contributor III
Author

The expression is:

PRODUCIDO   = Sum (QTYGOOD)

and

PERCENT  = (PRODUCIDO / PRODGOAL)

sunny_talwar
MVP
MVP

Try this

PRODUCIDO/
Sum(Aggr(
    If(Sum(QTYGOOD) = 0, 0, Sum(PRODGOALS))
, XnAreaDes.., WRKCTRID, ITEMID))

From the image, I couldn't determine the name of your first dimension, but you need to use that within the Aggr() function. 

JesusAlv4
Contributor III
Contributor III
Author

Thank you,

It works correctly, best regards.