Hi,
i have got an wingrid in which i need to show the summary of all the rows, but one of the columns is a calculated column in which even the summary needs to be calculated ..
i would like to check for the divide by zero exception ..
is there anyway by which i can check before i assign the formula
summaryPercentageAppliedForReceived.Formula = "Sum([" + _applliedForAmountLabel + "]) / " + "Sum([" + _ReceivedAmountLabel + "])" ;
but this will work as long as the "Sum([" + _ReceivedAmountLabel + "])" is greater than zero . else it will disaply something Like NaN
so what i am looking for is something like
if ( "Sum([" + _ReceivedAmountLabel + "])" > 0)
{
"Sum([" + _applliedForAmountLabel + "]) / " + "Sum([" + _ReceivedAmountLabel + "])" ;
}
else
" 0 ";
can you please let me know if there is any other way i can do this.
thank you for your help in advance,
You could use the "if" function:
if ( Sum([B] > 0, Sum([A] / Sum([B], 0 )
Hi Mike,
Thank you for your reply,
may be i am doing something wrong, because when i try to set the value for it using the following statements it actually says invalid expression
and does not complie.
summaryPercentageAppliedForReceived.Formula = if ( "Sum([" + _applliedForAmountLabel + "])" > 0, "Sum([" + _applliedForAmountLabel + "]) / "+ "Sum([" + _ReceivedAmountLabel + "])" , 0);
if i do this
summaryPercentageAppliedForReceived.Formula = "if ( " + "Sum([ _applliedForAmountLabel ] > 0 " + "," + " Sum([ _applliedForAmountLabel]) / Sum([ _ReceivedAmountLabel ]) " + ", " + " 0)" ;
it shows me syntax error.
summaryPercentageAppliedForReceived.Formula = "if ( Sum([ _applliedForAmountLabel ]) > 0 , Sum([ _applliedForAmountLabel]) / Sum([ _ReceivedAmountLabel ]) , 0)" ;
it shows me #Ref! sign in the grid column.
if possible if you can send me some sample code how i can do it. it will be helpful for me.
Thank you.
It's really hard to read an interpret the code like this. I might be better if you did a Debug.Writeline and looked at the resulting string of your formula.
But I do see some obvious errors here.
raghav_sai said:summaryPercentageAppliedForReceived.Formula = if ( "Sum([" + _applliedForAmountLabel + "])" > 0, "Sum([" + _applliedForAmountLabel + "]) / "+ "Sum([" + _ReceivedAmountLabel + "])" , 0);
You seem to have placed the "if" outside of the string here. "if" is a function - it needs to be part of the string.
raghav_sai said:summaryPercentageAppliedForReceived.Formula = "if ( " + "Sum([ _applliedForAmountLabel ] > 0 " + "," + " Sum([ _applliedForAmountLabel]) / Sum([ _ReceivedAmountLabel ]) " + ", " + " 0)" ;
You are missing some parens here.
raghav_sai said:summaryPercentageAppliedForReceived.Formula = "if ( Sum([ _applliedForAmountLabel ]) > 0 , Sum([ _applliedForAmountLabel]) / Sum([ _ReceivedAmountLabel ]) , 0)" ;
A #REF error means one of the references here does not exist. Either applliedForAmountLabel or _ReceivedAmountLabel are not valid column names.
I have a problem related to the summarysettings in Wingrid.the problem is that:
"I have 2 bands the first band is the description of products and the second band is the details of each product such as price, stock, etc... I use summarysettings for band1 and it is ok. Now I want to get the total price(band1 column) of each product to show in band0...I tried to use WinCalc Manager and use formula .. it shows ok but when I debug the program in the column it shows !Ref.... and no result...:("....
Is it possible to help me...this is very important for me ..
Thank you...
CalcManager calculations are performed Asynchronously by default. So you are probably debugging before the calculation has been performed and since the application is locked while you are debugging, it will not be performed until you let the program run.
Since I'm not sure what you are doing or what you are trying to debug, or why you need the value of this cell while debugging, I'm not sure what you can do about this.
You could set the CalcManager to operate in synchronous or manual mode using the CalcFrequency property. You might also need to set DeferredCalculationsEnabled to false to prevent the CalcManager from optimizing for visible rows and cells in the grid. Either of these changes will have performance implications for your application, though. So perhaps you can turn them on for debugging purposes and then switch them back when you are done.
It sounds like what you want is answered here:
Grandtotal on a child summary? - Infragistics Community
Thank you very much for your feedback.. But I think I couldnt define my question well .So I want to ask the same question in this way:
My band 0 has these columns:Order No, Order Type, Order Date,Details.
My band1 has these columns: Order No,Product No, Product Name, Product Price, Product Total Price...
In band1 I can sum "Product Total" easily but I want to sum all "Product Total" to show in band0 as grand total..
Can you help me please...
Thank you very much