Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
nikhilgarg
Specialist II
Specialist II

Prob in P() and E()

Hey,

I am trying to implement the P() and E() in sample application but couldn't do so.

In P() expressions, it seems they are not giving the expected results.

Can anyone help me in this?

Thanks

9 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

What are you trying to do?

What results do you get? And what do you expect?

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
rubenmarin

Hi Nikhil, I see it right, in example:

Sum({<Customer = P({<Product = {'Shoe'}>}Customer)>}Sales)

It's translated as: Summarize the sales of the customers who has buy 'Shoe'. Thats all the sales of those customers, not only the 'Shoe' Sales.

Shoe was sold to Cutomer1, customer2 and [blank] customer, so it's the same as:

Sum({<Customer={'','Customer1','Customer2'}>}Sales) //Wich result is 1800

Sales Customer '': 1500

Sales Customer 'Customer1': 100

Sales Customer 'Customer2': 200

hic
Former Employee
Former Employee

What in the result is unexpected? If I select 'Shoe', I get the following result:

Image2.png

and this corresponds in my mind quite well with what the P() function returns: You have numbers for the correct suppliers (blank, 3, 4 and 5) but 0 for the excluded ones (1, 2 and 6).

HIC

nikhilgarg
Specialist II
Specialist II
Author

Hey,

But as per my understanding,

P({<Product = {'Shoe'}>}Customer)

will give the sum of sales for Customer only and not for Suppplier.

Please correct me if i am wrong.

Thanks

nikhilgarg
Specialist II
Specialist II
Author

Hey,

But as per my understanding,

P({<Product = {'Shoe'}>}Customer)

will give the sum of sales for Customer only and not for Suppplier.


also if you see in 2nd a nd 3rd expression, i want sum of sales but i am getting sum for other products as well

Please correct me if i am wrong.

Thanks

nikhilgarg
Specialist II
Specialist II
Author

Hey,

But as per my understanding,

P({<Product = {'Shoe'}>}Customer)

will give the sum of sales for Customer only and not for Suppplier.


also if you see in 2nd a nd 3rd expression, i want sum of sales but i am getting sum for other products as well

Please correct me if i am wrong.

Thanks

hic
Former Employee
Former Employee

No, it has nothing to do with the sum of sales. The P() returns the Customers that are associated with 'Shoe'. That's all.

And when you use the above function the way you do, you will get sum of sales for customers that are associated with 'Shoe'. All sales, independent of product and supplier. The only filter is on customers.

HIC

hic
Former Employee
Former Employee

If you want sum of sales only for 'Shoe', you should use

   Sum({<Product = {'Shoe'}>}Sales)

and if you, in addition, want to exclude records where the customer is NULL, you should use

   Sum({<Product = {'Shoe'}, Customer={"*"}>}Sales)

HIC

rubenmarin

P({<Product = {'Shoe'}>}Customer) returns the customers who has relation with product Shoe, if you want only Shoe sales you can add that condition to set analysis:

Sum({<Customer = P({<Product = {'Shoe'}>}Customer), Product = {'Shoe'}>}Sales)

Wich doesn't makes more sense as you can directly ask for Product = {'Shoe'}.


It can be usefull in something like:

Sum({<Customer = P({<Product = {'Shoe'}>}Customer), Product = {'Socks'}>}Sales)

It returns the sales of Socks for the customers who has a relation with Shoe