Question
Last activity: 4 May 2020 14:47 EDT
How do I calculate the percentage of two clipboard property values?
I am trying to divide the "passing" and "total" clipboard properties and multiply by 100 to come up with a percentage and display that in a section. Please provide steps in how to do this. Thank you!
***Edited by Moderator Marissa to update Platform Capability tags****
Thank you for the reply Kanap, but I am trying to create a function that will have the values act as parameters because another case will not have the same numbers. Please guide me how to accomplish this.
The above one is for sample, Instead of numbers you can directly use properties inside the divide function like divide(.passing*100/.total) and set this value for the required property.
I am unable to accomplish the task this way. Let me show you what I am trying to reference. I have posted pictures below showing what exactly I need to use. Thank you again for the help.
Hi,
Can you try setting the values of passing and total into parameters and try using divide(Param.Passing, Param.total)
I would do this in a data transform right? Sorry I am beginner to Pega.
Yes,You can do it in Data transform or activity
I see that this is regarding the response you are receiving from Service. In the response Data Transform, after the properties are mapped, you can use declare expression to calculate the percentage using the divide function as mentioned above.
Thank you Kanap. I have attempted to do so but an error is occurring.
Could you please check the clipboard structure of connectRest.response_POST.results_Summary.tests and define each page connectRest,response_POST.,esults_Summary.,tests in pages and classes with resepective class.
And one more thing, I think the above page is related to Response you received from REST integration and you can handle the mapping in the response Data Transform itself, instead of having a new Data Transform.
Hi,
From your original screenshot when you created the post, you have passing and total properties already populated with values. You can try calling the function as below,
divide(.passing*100,.total)
There is a typo-mistake in my above reply. It meant to be divide(.passing*100,.total)
I was able to get it to work with the expression I have attached. Thank you for the help Kanap!
You can use the divide function to achieve this. Please find the below screenshot for more details.