Search code examples
visual-studio-2010crystal-reports

Exclude data with null values in crystal report


I have this formula in crystal reports

Global NumberVar Array Z := [
IF isnull({MIPIRReport;1.1}) then 0 else tonumber({MIPIRReport;1.1}) , 
IF isnull({MIPIRReport;1.2}) then 0 else tonumber({MIPIRReport;1.2}) , 
IF isnull({MIPIRReport;1.3}) then 0 else tonumber({MIPIRReport;1.3}) , 
IF isnull({MIPIRReport;1.4}) then 0 else tonumber({MIPIRReport;1.4}) , 
IF isnull({MIPIRReport;1.5}) then 0 else tonumber({MIPIRReport;1.5}) , 
IF isnull({MIPIRReport;1.6}) then 0 else tonumber({MIPIRReport;1.6}) , 
IF isnull({MIPIRReport;1.7}) then 0 else tonumber({MIPIRReport;1.7}) , 
IF isnull({MIPIRReport;1.8}) then 0 else tonumber({MIPIRReport;1.8}) , 
IF isnull({MIPIRReport;1.9}) then 0 else tonumber({MIPIRReport;1.9}) , 
IF isnull({MIPIRReport;1.10}) then 0 else tonumber({MIPIRReport;1.10}) ];

Minimum (Z)

What I would want is when the data is null, It should be excluded in my report

For graphical example, The values would be like this:

1.1,1.2,1.9,1.5,1.88,0,0,0,0,0

where the 0 represents the null and the 1 represents the values.

I would like to get the minimum value, which would be 1.1 and not 0. How should I do it?

Do take note that each number in the example is a different field in my crystal report which is so named as:

1,2,3,4,5,6,7,8,9,10

Solution

  • You can try 2 ways.

    If you want to store null values then you can take 2 arrays one for storing only 0 that is null and another array to store other values.

    If you don't need 0 to be stored then change formula this way:

    Global NumberVar Array Z;
    
    IF isnull({MIPIRReport;1.1}) then 0 else Z:= tonumber({MIPIRReport;1.1}) , 
    IF isnull({MIPIRReport;1.2}) then 0 else Z:= tonumber({MIPIRReport;1.2}) , 
    IF isnull({MIPIRReport;1.3}) then 0 else Z:= tonumber({MIPIRReport;1.3}) , 
    IF isnull({MIPIRReport;1.4}) then 0 else Z:= tonumber({MIPIRReport;1.4}) , 
    IF isnull({MIPIRReport;1.5}) then 0 else Z:= tonumber({MIPIRReport;1.5}) , 
    IF isnull({MIPIRReport;1.6}) then 0 else Z:= tonumber({MIPIRReport;1.6}) , 
    IF isnull({MIPIRReport;1.7}) then 0 else Z:= tonumber({MIPIRReport;1.7}) , 
    IF isnull({MIPIRReport;1.8}) then 0 else Z:= tonumber({MIPIRReport;1.8}) , 
    IF isnull({MIPIRReport;1.9}) then 0 else Z:= tonumber({MIPIRReport;1.9}) , 
    IF isnull({MIPIRReport;1.10}) then 0 else Z:= tonumber({MIPIRReport;1.10}) ;
    
    Minimum (Z)
    

    Let me know how it goes