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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikwiz123
Creator III
Creator III

Cost Calculation

I have the below fields

 

ID,

Mono,

Group,

Total

CostPerMono,

CostPerGroup

 

I need to create Costs such that

If an ID has values in either Mono or Group or both,

MonoCost = CostPerMono * Mono

GroupCost = CostPerGroup * Group

If an ID has no values in Mono and Group fields, then 

MonoCost = 25% of Total * CostPerMono

GroupCost = 75% of Total * CostPerGroup.

 

How do I do this in the script ?

Labels (3)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

Try something like below:

LOAD

ID,

Mono,

Group,

Total

CostPerMono,

CostPerGroup,

CostPerMono * alt(Mono, Total*0.25) as MonoCost,

CostPerGroup * alt(Group, Total*0.25) As GroupCost

 

View solution in original post

2 Replies
Vegar
MVP
MVP

Try something like below:

LOAD

ID,

Mono,

Group,

Total

CostPerMono,

CostPerGroup,

CostPerMono * alt(Mono, Total*0.25) as MonoCost,

CostPerGroup * alt(Group, Total*0.25) As GroupCost

 

qlikwiz123
Creator III
Creator III
Author

Hi @Vegar 

 

Thank you. Had to tweak it to check for null values.