Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
souadouert
Specialist
Specialist

VARIABLE WITH DYNAMIC NAME

Hello i have this table

  

ID_SALERPRODUCTCATEGORIEsalesCLIENT_PRODUCT
100P1c150010
100P2c1250010
102P1c350212
102P2c450313

and i have variables $(P1) ET $( P2)

P1=sum({<CATEGORIE={'C1'},sales={'<700'}>}1)

P2=sum({<CATEGORIE={'C5'},sales={'<700 >200'}>}1)

SO I need to create simple table , in dimension ID_saler and Product

and in expression i need to add the variable with corresponding to value dimensions --> =$(PRODUCT)

 

ID_SALERPRODUCTEXPRESSION
100P1$(PRODUCT)$(P1)
100P2$(PRODUCT)$(P2)
102P1$(PRODUCT)$(P1)
102P2$(PRODUCT)$(P2)

but iwhen i excuted , the expression shows the text expression

sum({<CATEGORIE={'C1'},sales={'<700'}>}1)

sum({<CATEGORIE={'C5'},sales={'<700 >200'}>}1)

So i need to force the interpretation

Capture.PNG

1 Solution

Accepted Solutions
stigchel
Partner - Master
Partner - Master

The problem is that $ sign expansions are on a chart level and do not work with row by row dimension values. You probably need to use a pick match construction like =Pick(Match(Product,'P1','P2'),$(P1),$(P2)). To make this variable have a look at (and the links in there)

Re: Using Pick and Match for multiple calculations

View solution in original post

6 Replies
YoussefBelloum
Champion
Champion

Hi,

what is the content of the variable $(PRODUCT) ?

you are using two variables in your expression ?

souadouert
Specialist
Specialist
Author

Hello,

the idea is that the dynamic variable name according to the value of the dimension product

Capture.PNG

and P1 and P2

P1=sum({<CATEGORIE={'C1'},sales={'<700'}>}1)

P2=sum({<CATEGORIE={'C5'},sales={'<700 >200'}>}1)

YoussefBelloum
Champion
Champion

a simple IF won't do the trick ?

if(PRODUCT='P1', $(P1), $(P2))

souadouert
Specialist
Specialist
Author

youssef I do not have the list of products,I must have as much product as dynamically variable

stigchel
Partner - Master
Partner - Master

The problem is that $ sign expansions are on a chart level and do not work with row by row dimension values. You probably need to use a pick match construction like =Pick(Match(Product,'P1','P2'),$(P1),$(P2)). To make this variable have a look at (and the links in there)

Re: Using Pick and Match for multiple calculations