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

Convert String value to Float

1 Answer 1335 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lukas
Top achievements
Rank 1
Lukas asked on 27 Mar 2019, 03:03 PM

Hello,

in my project i need to sum values from DB column which contains string values too (column Value (type String)). I have information about type of Value (column Type).

Please is possible to write expression for conversion Value from type String to type Float and then SUM all this numeric values?

 

Simplified model:

ID    Value    Type

================

1      5,21      number

2      text 1    string

3      4,56      number

4      text 2    string

 

And i need summary: 5,21 + 4,56 = 9,77

Thanks for any idea.

Lukas

 

Telerik Report Designer v11.2.17.1025

 

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 29 Mar 2019, 02:47 PM
Hi Lukas,

The total can be calculated through the Aggregate function Sum. However, for each value, you need to check the type and if it is a number to convert it to double. The expression might look like: 

="Total: " + Sum(CDbl(IIF(Fields.Type = 'number',Fields.Value, 0)))

The attached report demonstrates the solution. Keep in mind that a CSV data source is used where the double values are separated by a dot (instead 5,21, 5.21 is used).

Regards,
Neli
Progress Telerik
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
Tags
General Discussions
Asked by
Lukas
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or