Skip to main content
Solved

GP% formula

  • January 9, 2026
  • 1 reply
  • 37 views

Forum|alt.badge.img

I am building this GI to get GP$. it seems like the formulas I am using is not giving me the accurate answer. Can someone please check formula to see if I have the right one.

 

=IIf(    [ARTran.TranDate] >= '2025-01-01'    And [ARTran.TranDate] < '2026-01-01',    [ARTran.CuryTranAmt] - [ARTran.Cost],    0)

Best answer by aleksandrsechin

Hi ​@SandyA 
The issue is that ARTran.Cost is an unbound field, so it cannot be used in a Generic Inquiry. Instead of referencing this field directly, you need to calculate its value in the GI using the same logic as defined in the DAC attribute:

[PXDBCalced(typeof(Mult<Switch<Case<Where<drCr, Equal<DrCr.debit>>, PX.Data.Minus<decimal1>>, decimal1>, Switch<Case<Where<isTranCostFinal, Equal<False>>, tranCostOrig>, tranCost>>), typeof(decimal))]

 So your formula should look as follows:

=IIf([ARTran.TranDate] >= '2025-01-01' And [ARTran.TranDate] < '2026-01-01',[ARTran.CuryTranAmt] - (IIf([ARTran.DrCr] = 'D',-1,1) * IIf([ARTran.IsTranCostFinal] = False,[ARTran.TranCostOrig],[ARTran.TranCost])),0)

 

1 reply

Forum|alt.badge.img+4

Hi ​@SandyA 
The issue is that ARTran.Cost is an unbound field, so it cannot be used in a Generic Inquiry. Instead of referencing this field directly, you need to calculate its value in the GI using the same logic as defined in the DAC attribute:

[PXDBCalced(typeof(Mult<Switch<Case<Where<drCr, Equal<DrCr.debit>>, PX.Data.Minus<decimal1>>, decimal1>, Switch<Case<Where<isTranCostFinal, Equal<False>>, tranCostOrig>, tranCost>>), typeof(decimal))]

 So your formula should look as follows:

=IIf([ARTran.TranDate] >= '2025-01-01' And [ARTran.TranDate] < '2026-01-01',[ARTran.CuryTranAmt] - (IIf([ARTran.DrCr] = 'D',-1,1) * IIf([ARTran.IsTranCostFinal] = False,[ARTran.TranCostOrig],[ARTran.TranCost])),0)