Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: assign string to number Post Reply Post New Topic
Author Message
lalakeyorai
Newbie
Newbie


Joined: 01 Nov 2009
Online Status: Offline
Posts: 19
Quote lalakeyorai Replybullet Topic: assign string to number
    Posted: 07 Nov 2009 at 11:22pm

i have a problem to assign value to a string. in my database, there is a column called 'Event_Status' where this column, consists two status which is 'active' and 'clear'.

these two status is indicating the status of another column called 'Event_Name' and this column consist the event called 'devdown' (device down) and 'unresponsive'. here the example of my data:


Event_Name                    Event_Status
devdown                               active
devdown                               clear
devdown                               active
devdown                               clear
unresponsive                         active
unresponsive                         clear
unresponsive                         active
unresponsive                         clear



is it possile for me to assign value '1' for active and '0' for clear so that im able to generate the line chart based on this data. how can i do that? is there any relevant CR syntax or SQL syntax that i can use? please advice.

Thank you in advance



Edited by lalakeyorai - 07 Nov 2009 at 11:25pm
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 09 Nov 2009 at 6:33am
Create a formula field to use that is:
 
if {table.event_status} = 'active'
     then 1
          else
if {table.event_status}='clear'
     then 0
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 09 Nov 2009 at 6:35am
I've never used it, but if you are joining straight to the tables you can use 'SQL Expressions' which hopefully will convert it.  For display you could write a formula, but I don't know if that will work with a chart (my company doesn't use charts, just lots of numbers).
 
if you are getting the data from a stored proc, just change it in your stored proc, or add a column something like:
CASE WHEN Event_Status = 'active' THEN 1 ELSE 0 END AS newColumnName
 
added to a select statement should work.
IP IP Logged
lalakeyorai
Newbie
Newbie


Joined: 01 Nov 2009
Online Status: Offline
Posts: 19
Quote lalakeyorai Replybullet Posted: 09 Nov 2009 at 6:35pm

Thank you so much for both responses. those are the exactly solution that im looking for... thank you very much...

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.