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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
lfalmoguera
Creator
Creator

Use fieldNames within a table to determine algorithm and get a result

Hi all.

I am struggling with something that should be reallly easy 😞

I have this table:

fieldAfieldBalgorithm
13fieldA*fieldB
24fieldB
28fieldB/fieldA

 

and just want to obtain a result field such as:

 

fieldAfieldBalgorithmresult
13fieldA*fieldB3
24fieldB4
28fieldB/fieldA4

 

How do I "catch" fieldA and field B to get result?

I need to "make it" within the script.

Thanks in advance!
Kind regards.

Labels (2)
1 Solution

Accepted Solutions
danilostochi
Creator II
Creator II

 hi, here this a possible solution

dados:
LOAD
Trim(PurgeChar(algorithm,'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B')) AS CAL,
if(Trim(PurgeChar(algorithm,'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B'))='*',fieldA * fieldB,
if(Trim(PurgeChar(algorithm,'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B'))='/',fieldB / fieldA,
if(Trim(PurgeChar(algorithm,'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B'))='',fieldB
)
)
) as Result,


* Inline [
fieldA, fieldB, algorithm
1, 3, fieldA * fieldB
2, 4, fieldB
2, 8, fieldB / fieldA
];

danilostochi_0-1587320979428.png

 

+55(44) 9 9993-3605, WhatsApp
E-Mail or Skype - danilo16stochi@hotmail.com

View solution in original post

1 Reply
danilostochi
Creator II
Creator II

 hi, here this a possible solution

dados:
LOAD
Trim(PurgeChar(algorithm,'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B')) AS CAL,
if(Trim(PurgeChar(algorithm,'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B'))='*',fieldA * fieldB,
if(Trim(PurgeChar(algorithm,'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B'))='/',fieldB / fieldA,
if(Trim(PurgeChar(algorithm,'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B'))='',fieldB
)
)
) as Result,


* Inline [
fieldA, fieldB, algorithm
1, 3, fieldA * fieldB
2, 4, fieldB
2, 8, fieldB / fieldA
];

danilostochi_0-1587320979428.png

 

+55(44) 9 9993-3605, WhatsApp
E-Mail or Skype - danilo16stochi@hotmail.com