This is a migrated thread and some comments may be shown as answers.

How To Display nothing when fields's value is 0

7 Answers 5118 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Arthur Wu
Top achievements
Rank 1
Arthur Wu asked on 14 Jul 2010, 03:10 AM
Hi
In my report. There're few fields in a Table which value is 0
but i want let it display nothing(like "") when User Preview.
because there are 10~20 Report in my Project.and in each Report. there are 3~5 Table in Each Report.
so~ is any solution can solve my problem?

below is my printscreen. hope to let u know my question.
http://ppt.cc/pr@y
if picture failed.plz tell me.

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 15 Jul 2010, 01:43 PM
Hello Arthur Wu,

You can use the built-in IIF function to create an expression which checks what is the value and changes it if needed.

Greetings,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Arthur Wu
Top achievements
Rank 1
answered on 19 Jul 2010, 09:20 AM
Hi Steve,

Thanks for your answer.
i know how to use "IIF" in Expression to show "".
but my point is is there any way to setting up at one time?

EX:
Set this Expression(= IIF(Fields.* = 0,"",Fields.*) to some "Report", not just set to one "Fields".
So that i don't need to set each fields of table in my report.

thanks again.
0
Svetoslav
Telerik team
answered on 22 Jul 2010, 10:19 AM
Hello Arthur Wu,

You can add Calculated Fields to your data source and use them the same way as the real fields of the data source. Of course you have to create such expressions/calculated fields for all fields that you like to render as empty strings instead of 0s.

Sincerely yours,
Svetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Edson
Top achievements
Rank 1
answered on 21 Oct 2010, 06:42 PM
You can create a method to check if the field value is zero, if is true leave it as String.Empty otherwise apply the format you want.

First - Create the method ( In My case I want to display a value with one decimal digit when the value is not zero)

private void DisplayNumber(object sender, EventArgs e) 
{
    Telerik.Reporting.Processing.TextBox textbox = sender as Telerik.Reporting.Processing.TextBox; 
       
   double value = 0; 
   double.TryParse(textbox.Value.ToString(),out value); 
  
   if (vaue == 0) textbox.Value = string.Empty; 
   else textbox.Value = value.ToString("N1"); 
 }

 

Second - Set the method DisplayNumber to Event ItemDataBound of each textBox on report that you want apply this feature.

That´s  all !
 

0
Mark
Top achievements
Rank 1
answered on 22 Feb 2017, 03:30 AM

An old post, but whilst the above methods work, when the report is exported to Excel all the numbers are exported as strings and typical excel functions (such as sum) will not work on them. Any way around this?

 

0
Stef
Telerik team
answered on 24 Feb 2017, 12:58 PM
Hi Mark,

The following expression returns an Integer value (the type of the fields), and calculations in Excel are correct:
=IIf( Fields.Column1=0,Null,Fields.Column1)
The attached demo report can be used for testing. The report is created with the Standalone Report Designer of Telerik Reporting R1 2017 SP1.

Please check if the fields are of numeric type, and if you use the Format text function or TextBox.Format property reset it to avoid converting the numeric values to formatted strings. Note that formats are saved as custom formats in Excel files - Design Considerations for Excel Rendering.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ahmed
Top achievements
Rank 1
answered on 02 Mar 2017, 09:22 PM
I Have too much $values and much of them is ZERO, I want to suppress these Zeros values to be empty string
Tags
General Discussions
Asked by
Arthur Wu
Top achievements
Rank 1
Answers by
Steve
Telerik team
Arthur Wu
Top achievements
Rank 1
Svetoslav
Telerik team
Edson
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Stef
Telerik team
Ahmed
Top achievements
Rank 1
Share this question
or