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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
cclayford
Partner - Creator
Partner - Creator

How do i use the P() function?

Hi

I am currently using these expressions to calculate the following:

Sum for first 3 months:

sum({<Month={'>=$(=min(Month))<=$(=min(Month)+2)'}>}[Total Units])

Sum for last 3 months:

sum({<Month={'>=$(=max(Month)-2)<=$(=max(Month))'}>}[Total Units])

My dimension is [Meter Serial Number]

How would i use the P() function to only show the sum for the specific [Meter Serial Number] in the row?

Thanks,

Christopher.

4 Replies
nizamsha
Specialist II
Specialist II

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. 

SEE THE HELP FOR MORE INFORMATION

cclayford
Partner - Creator
Partner - Creator
Author

I tried this in my expression, but it does not bring back the desired result:

sum({$<[Meter Serial Number] = P([Meter Serial Number])>}{<Month={'>=$(=min(Month))<=$(=min(Month)+2)'}>}[Total Units])

nizamsha
Specialist II
Specialist II

sum({$<[Meter Serial Number] = P({1<Month={'>=$(=min(Month))<=$(=min(Month)+2)'}>}[Meter Serial Number])>}[Total Units])


swuehl
MVP
MVP

You want the set expression to consider the current dimension value? A set expression is only evaluated once, not per dimension value, you can compare it to a user selection that's specific to that aggregation, that defines the working set for that aggregation.

Please check this blog post, where you may find also a work around:

Evaluating "sets" in the context of a dimension