Print Page | Close Window

assign string to number

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=8264
Printed Date: 01 May 2024 at 9:59pm


Topic: assign string to number
Posted By: lalakeyorai
Subject: assign string to number
Date 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




Replies:
Posted By: FrnhtGLI
Date 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


Posted By: lockwelle
Date 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.


Posted By: lalakeyorai
Date 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...




Print Page | Close Window