Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
male_carrasco
Creator
Creator

P() Variables

Hola,

Estoy calculando el % de clientes que compraron por ejemplo el producto A y B.

Ejemplo:

Count({1<Cliente = P({<Producto = {'A'} >})*P({<Producto = {'B'} >})>}Distinct Cliente)/ Count({1}DISTINCT Cliente)

Necesito que sea una formula dinámica que calcule el % según los productos seleccionados.

Desde ya muchas gracias por la ayuda.

Adjunto ejemplo

Slds,

Ale.

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

Try using the formula:

=num(Count({1<Cliente = $(=concat(distinct 'P({<Producto = {' & Producto & '} >})', '*'))>}Distinct Cliente)/ Count({1}DISTINCT Cliente),'#.###,%')

Hope this helps!

View solution in original post

5 Replies
Anonymous
Not applicable

you are missing field names in your p() function. try this:

Count({1<Cliente = P({<Producto = {'A'} >}Cliente)*P({<Producto = {'B'}>Cliente)})>}Distinct Cliente)

you could combine them too I would think, something like

Count({1<Cliente = P({<Producto += {'A','B'} >}Cliente)})>}Distinct Cliente)

for the percentage you could use num function...wrap the entire expression in num(), for example,

num(/*your expression*/,'##.#%')

male_carrasco
Creator
Creator
Author

Thanks jsaradhi<http://community.qlik.com/people/jsaradhi>

I need to be a dynamic formula that calculates the% according to selection.

Please see attached.

Ale.-

Anonymous
Not applicable

sorry...i misunderstood your requirement. let me look into it.

jerem1234
Specialist II
Specialist II

Try using the formula:

=num(Count({1<Cliente = $(=concat(distinct 'P({<Producto = {' & Producto & '} >})', '*'))>}Distinct Cliente)/ Count({1}DISTINCT Cliente),'#.###,%')

Hope this helps!

male_carrasco
Creator
Creator
Author

Thanks jerem1234