Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I keep getting Invalid Expression with the following load script:
Insource%:
Load
AcctDesc,
Cost,
If(AcctDesc='Demand Service' or AcctDesc='Demand Parts',Sum(Cost),0)/Sum(Cost) as Insource
Resident MasterCostTable;
- add a group by
- I don't understand the if, it seems sum(Cost) / sum(Cost) or 0 / sum(Cost), so 1 or 0
Insource%:
Load
AcctDesc,
Cost,
//If(AcctDesc='Demand Service' or AcctDesc='Demand Parts',Sum(Cost),0)/Sum(Cost) as Insource
If(AcctDesc='Demand Service' or AcctDesc='Demand Parts',Sum(Cost),0) as Insource
Resident MasterCostTable
group by AcctDesc, Cost;
- add a group by
- I don't understand the if, it seems sum(Cost) / sum(Cost) or 0 / sum(Cost), so 1 or 0
Insource%:
Load
AcctDesc,
Cost,
//If(AcctDesc='Demand Service' or AcctDesc='Demand Parts',Sum(Cost),0)/Sum(Cost) as Insource
If(AcctDesc='Demand Service' or AcctDesc='Demand Parts',Sum(Cost),0) as Insource
Resident MasterCostTable
group by AcctDesc, Cost;
The If statement is declaring a subset of costs to divide by the total cost.
What Maxgro said.
Maybe this if you actually want your costs summed up in the script:
Insource%:
Load
AcctDesc,
sum(Cost)as Cost,
sum(If(AcctDesc='Demand Service' or AcctDesc='Demand Parts',Cost,0))/Sum(Cost) as Insource
Resident MasterCostTable
group by AcctDesc;
I am wondering if you wouldn't want to do this in a chart. Then you could use the Total keyword in your expression.