Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
jham55
Contributor II
Contributor II

If statement with multiply function

I have 4 different rates that I want to multiply against depending on a location.  Here is my example

column1  is

atlanta    

chicago

cleveland

Miami

column 2 cost

cost

column 3 rate

4

5

2

6

So atlanta needs to be cost * 4

chicago needs to be cost * 5

etc.

 

any thoughts?

Labels (1)
  • Chart

7 Replies
Digvijay_Singh

If its in a same script table, then may be like this - 

pick(match(Location, 'atlanta','chicago','cleveland','Miami'),

cost*4, cost*5, cost*2,cost*6) as value;

jham55
Contributor II
Contributor II
Author

Thanks it’s just a table chart right now. 

Digvijay_Singh

Not sure but if all the fields are in the same table or properly associated, this should work I think in table chart as well..

Lisa_Sun
Support
Support

Example code. 

Location:
Load * Inline [

location, cost, rate
atlanta, 1000
chicago,2000
cleveland,345
Miami,5667
];

LocationCost:

load
location,
pick(match(location,'atlanta','chicago','cleveland','Miami'),cost*4,cost*5,cost*2,cost*6) as locationcost,
if(location='atlanta',4,(if(location='chicago', 5,if(location='cleveland',2,if(location='Miami',6))))) as rate
Resident Location;

Help users find answers! Don't forget to mark a solution that worked for you! If already marked, give it a thumbs up!
jham55
Contributor II
Contributor II
Author

Thanks-- didnt work though.

Digvijay_Singh

Pl share your table chart, expected output etc  Its difficult to identify problem without knowing what and where you are trying the shared expression

Lisa_Sun
Support
Support

@jham55   please find from the attached qvf.

Help users find answers! Don't forget to mark a solution that worked for you! If already marked, give it a thumbs up!