Question
Pegasystems Inc.
US
Last activity: 6 Dec 2016 2:42 EST
Declare Expression should not use nulls in page list
I have the following declare expression:
Set prop_x = Average of prop_page_list().prop_y using entries in which _________
The issue is that I need this:
Set prop_x = Average of prop_page_list().prop_y using entries in which prop_page_list().prop_y > 0
However > or any relational operator is not alllowed in that field. How do I work around this? I must use a declarative to compute the value for prop_x
***Moderator Edit: Vidyaranjan| Updated Categories***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
US
After further tests and investigation I have confirmed that there is no bug after all. I am reworking the solution that produced the error-laden data; this discussion is resolved.
Pegasystems Inc.
IN
Hello Salazone,
Thanks for posting your query in PSC :)
Would using data transform help at your end?
Can you mention below:
- Pega version used
- Screenshots of the configuration made for the PageList, Declare Expression. I would like to see the class hierarchy of PageList.
Regards,
Rincy
Pegasystems Inc.
US
Hi Rincy,
Attached is what I have now. This saves, but it does not produce the desired result because when Prop_y is null, it is still being included in the average. For example, if I have .Prop_Page_List(1).Prop_y = 1; .Prop_Page_List(2).Prop_y = null; .Prop_Page_List(3).Prop_y = 2; then I expect the .Prop_x to be 1.5 since the null should not be included in the average. However, this declarative is giving the answer as 1.0 since it is including the null in the average.
I need the declarative to not count Prop_y when it's value is 0 or null.
Using PRPC 7.1.8.
A data transform will not help because there is nothing for the DT to transform; if the value is null it should not be included when the declarative averages each property in the page list.
Pegasystems Inc.
IN
Hi Salazone,
Is your scenario something like this :
Here you want to calculate, only if the pagelist.ID is >0 ?
Pegasystems Inc.
US
Yes, that is what I want to do. I tried changing my declarative to match what you have here and I came up with the same result (nulls are being included).
Pegasystems Inc.
US
I believe this is a bug with delclare expressions so I will file a bug.
Pegasystems Inc.
IN
Hi,
I dont think this is a bug from the product . When a pagelist contains an empty value, that will also be included to find the average . For example the avg of {0,1,2,3,0} will be 6/5 = 1.2
Your usecase can be considered as a requirement , where in the declare expression, an addtional option need to be provided to validate empty values .
Pegasystems Inc.
US
The problem is that in the declare expression I am explicitly saying "do not count values in which the property is 0" (see screenshot). So in your example, {0,1,2,3,0}, not counting the 0 values the average should be 6/3 = 2
Accepted Solution
Pegasystems Inc.
US
After further tests and investigation I have confirmed that there is no bug after all. I am reworking the solution that produced the error-laden data; this discussion is resolved.