on ‎2014 Aug 20 4:55 PM
Let's assume column XYZ has both numbers (1), and letters (any alphabet).
I have a case statement on SQL to turn any value that's not 1 into 0, then I am getting a sum of that column.
I am also grouping by Row A, B etc to get aggregated sum of column XYZ for those group.
Now on Crystal Reports function, I need to sum up values under column XYZ for all the groups.
If I try using sum function like below, I get an error stating:
"A number field or currency amount field is required here"
(sum({Command.XYZ}))
So I thought if I can use a case statement to change the non-numbers to 0 prior to sum that will probably resolve it. But I could not get the below case statement to work either (Error: A string is required).
SELECT {Command.XYZ}
Case = 1:
1
Default:
0;
If I try using SWITCH, I receive an error for underlined below "A string is required here"
Switch(
{Command.XYZ} = 1, 1,
true, 0
)
Originally discussed on http://scn.sap.com/thread/1050589
Request clarification before answering.
Hi Ashish,
You said "I have a case statement on SQL to turn any value that's not 1 into 0, then I am getting a sum of that column." and "Now on Crystal Reports function, I need to sum up values under column XYZ for all the groups"
So, are you trying to create a similar function in CR or are you trying to just sum up the values that you bring in from the database?
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is telling me that the data in the {Command.XYZ} field is a string. So, you have to compare it to a string.
In Switch, it will look like this:
Switch(
{Command.XYZ} = "1", 1,
true, 0
)
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.