Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
so I have a table of products that consist of supply cost, development cost and internal cost
Internal cost is calculated based on supply cost - development costs
I am trying to do all this in the load script in order to keep the interface charts clean. I am afraid that may not be possible
My data set looks like this
Products:
Load * inline [
Product, account, year, cost
Product1, Supply, 2020, 1000
Product1, Development,2020 2000
Product1, internals, 2020, // need to calculate this value
Product1, Supply, 2021, 3000
Product1, Development, 2021, 5000
Product1, Internal, 2021, // need to calculate this value
]
so the calculation would be development - supply = 1000
May be not the best solution but can be done like below
test:
load * ,Product&'-'&year as %KeyInline [
Product1, Development,2020, 2000
Product1, internals, 2020,
Product1, internals, 2021,
];
temp:Load %Key,sum(cost) as DevelopmentCostResident testwhere account='Development'group by %Key ;left join(temp)
Load %Key,sum(cost) as SupplyCostResident testwhere account='Supply'group by %Key ;MapInternalCost:Mapping Load%Key,DevelopmentCost-SupplyCost as InternalCostResident temp;
drop table temp;NoConcatenateTest1:Load *,if(account='internals',Applymap('MapInternalCost',%Key,null()),cost) as NewCostResident test;drop table test;