Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
What is P() & E() and where do you use them? and purpose of P() and E() ?
You can only use p() and e() function in a set analysis set modifier.
From the Help file:
In the above examples, all field values have been explicitly defined or defined through searches. There is however an additional way to define a set of field values by the use of a nested set definition.
In such cases, the element functions P() and E() must be used, representing the element set of possible values and the excluded values of a field, respectively. Inside the brackets, it is possible to specify one set expression and one field, e.g. P({1} Customer). These functions cannot be used in other expressions:
sum( {$<Customer = P({1<Product={‘Shoe’}>} Customer)>} Sales )
returns the sales for current selection, but only those customers that ever have bought the product ‘Shoe’. The element function P( ) here returns a list of possible customers; those that are implied by the selection ‘Shoe’ in the field Product.
sum( {$<Customer = P({1<Product={‘Shoe’}>})>} Sales )
same as above. If the field in the element function is omitted, the function will return the possible values of the field specified in the outer assignment.
sum( {$<Customer = P({1<Product={‘Shoe’}>} Supplier)>} Sales )
returns the sales for current selection, but only those customers that ever have supplied the product ‘Shoe’. The element function P( ) here returns a list of possible suppliers; those that are implied by the selection ‘Shoe’ in the field Product. The list of suppliers is then used as a selection in the field Customer.
sum( {$<Customer = E({1<Product={‘Shoe’}>})>} Sales )
returns the sales for current selection, but only those customers that never bought the product ‘Shoe’. The element function E( ) here returns the list of excluded customers; those that are excluded by the selection ‘Shoe’ in the field Product.
Regards,
Stefan
the use of P() and E() is a great functionality. Although i did not understand the part that I have copied below: what is meant by returns the sales for those customers that have supplied the product 'shoe'...? A supplier supplies a product and a customer buys it. May be I missed some thing. Can some one explain??
sum( {$<Customer = P({1<Product={‘Shoe’}>} Supplier)>} Sales )
returns the sales for current selection, but only those customers that ever have supplied the product ‘Shoe’. The element function P( ) here returns a list of possible suppliers; those that are implied by the selection ‘Shoe’ in the field Product. The list of suppliers is then used as a selection in the field Customer.
Thanks again!!!
There are at least four fields in that data model, Product, Supplier, Customer, Sales.
This example only makes sense if it's possible that values in field Customer, like 'Stefan', 'John', also appear in field Supplier. These entities than have two roles, they act as Customer as well as a Supplier.
Maybe it's not the best sample code to explain the p() function, but I think it's valid. It's there to explain that you can use the p() function to return possible values from a field (Supplier) other than the field you want to filter (Customer).
Hope this explains it a bit better.
Read below script
Indirect Set Analysis
• p( ) = Possible
• e( ) = Excluded
Excluded
Possible
Customer = p({<Year={$(=max(Year)-1)}>} Customer)
Returns customers who had an association to last year.
sum(({<Year={$(=max(Year))},
Customer = p({<Year={$(=max(Year)-1)} Customer>}) Sales)
Returns this year’s sales for customers who had sales last year
Indirect Set Analysis
sum({$<CompanyName = p({$<CategoryName={'Baby Clothes'}>}
CompanyName)>} Sales)
Sales for Customers who purchased Baby Clothes.
The set p({}) returns the values of CompanyName (Customer) that
purchased Baby Clothes.
sum({$<CompanyName = p({$<CategoryName={'Baby Clothes'}>}
CompanyName) - p({$<CategoryName={'SportsWear'}>}
CompanyName)>} Sales)
Sales for Customers who purchased Baby Clothes but not
Baby Clothes.The second set p({}) returns CompanyName that
Purchased SportsWear.The Unary Operator "-" between the two gives
a list of Customers (Company Name)that belong to the first but not the
other set
enti nagaraj see above script
if ur ok pls make it as a correct answer
Thanks !! understood what is P() AND E() tried to undertand it 100 times in past , may be today my state of
mind is correct or right that is why i can understand it is just nesting of a set analysis inside a set analysis .
Thanks Stefan
........................
Anant
very useful stefen. thank you
those last two links! So true.