Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]Alpha to numeric format
Go
New
Search
Notify
Tools
Reply
  
[SOLVED]Alpha to numeric format
 Login/Join
 
Guru
posted
Hi,

I have an alpha field(A40V) with the values such as (12.50%,2,89%,5.00% etc) and I want to change it to a numeric field.

Iam using the below code/logic but nothing seems to be working :
 DEFINE FILE NEW_TABLE
NEW_FIELD2/D12.2 = ATODBL(FIELD2,'40',NEW_FIELD2);

END

TABLE FILE NEW_TABLE
PRINT
FIELD2
COMPUTE NEWER_FIELD/P12.2=NEW_FIELD2;
END
-RUN

This is the output which Iam getting :

FIELD2 	NEWER_FIELD
12.50%	.00
2.89%	.00
5.00%	.00
.... 


Could anyone please let me know how to convert from alpha to numeric retaining the %'s ?
Please let me know.

Thanks a lot in advance for all the help.

Regards,
IP

This message has been edited. Last edited by: info4pal,


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
 
Posts: 270 | Registered: October 30, 2014Reply With QuoteReport This Post
Platinum Member
posted Hide Post
This is being very basic and would be learn in training.

Look for how use number format in document.

Kofi


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
 
Posts: 103 | Registered: April 06, 2009Reply With QuoteReport This Post
Guru
posted Hide Post
Hi Kofi,

In FPRINT,the output format should also be alphanumeric and I want my output format in numeric.

Please let me know.

Regards,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
 
Posts: 270 | Registered: October 30, 2014Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Look in documents for USAGE (same use for DEFINE and COMPUTE also) and learn how use percent sign on number.

Kofi


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
 
Posts: 103 | Registered: April 06, 2009Reply With QuoteReport This Post
Virtuoso
posted Hide Post
USAGE is good when your data is read from a master file.
If it comes from a HOLD file or defined in your TABLE FILE, you may not have a master from which you can change the USAGE.

This can do the job.
To have EDIT converting an "alpha-number" to a number, it must not have any spaces or special characters.
Sometimes you need to play with several functions and try stupid things to get what you need.
DEFINE FILE CAR
PCTA /A10V    = DECODE COUNTRY ('ENGLAND' '10.5%' 'FRANCE' '15.28%' 'ITALY' '-5.00%' 'JAPAN' '.05%' ELSE '100%');
PCTX /A10V    = TRIMV('B', CTRAN (10, PCTA, 37, 32, 'A10V'), 10, '', 1, 'A10V');
PCTD /D10.2%C = EDIT(TRIMV('B', CTRAN (10, PCTA, 37, 32, 'A10V'), 10, '', 1, 'A10V'));
END
TABLE FILE CAR
PRINT PCTA
      PCTX
      PCTD
BY COUNTRY
END
-RUN

This message has been edited. Last edited by: MartinY,


WF versions : Prod 8.2.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2234 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Guru
posted Hide Post
Hi Martin,

I actually want to convert the PIVOTFLD field
in this post which is in A40 format to numeric so that I can use it for my graph.
http://forums.informationbuild...1057331/m/4357087586

In this case, I can't use decode also as suggested in your example since I have multiple values right ?

Please let me know.

Regards,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
 
Posts: 270 | Registered: October 30, 2014Reply With QuoteReport This Post
Virtuoso
posted Hide Post
The DECODE was there only to create data as for the sample since no data similar to yours exist in IBI sample files.

In your case PCTA is replaced by PIVOTFLD in the PCTD field definition.

You need to analyse a little more and think "what can be applied to my case from the provided sample".

From all the posts regarding that report/graph "issue", I gave you all what you need to have the result.
I think that from this point, you have to think and work by yourself.
Try stuff, do more search, make errors and try back. You have all you need already.

This message has been edited. Last edited by: MartinY,


WF versions : Prod 8.2.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2234 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Platinum Member
posted Hide Post
quote:
PCTD /D10.2%C

Exactly!!! Learn number format by reading manual and document and not expect people do for you.

You lucky Martin so keen to answer and do your work!!

quote:
Look in documents for USAGE (same use for DEFINE and COMPUTE also) and learn how use percent sign on number.

Martin, USAGE OK on synonym as you say. Is why I say same use for DEFINE and COMPUTE. I try give enough to help go forward but not complete answer - this way IP may learn??

Kofi


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
 
Posts: 103 | Registered: April 06, 2009Reply With QuoteReport This Post
Virtuoso
posted Hide Post
It's right Kofi, but using format attributes may not be enough since it may not converting from one type to another.
Often it's just a display feature attribute.


WF versions : Prod 8.2.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2234 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Guru
posted Hide Post
Hi,

Thanks Kofi Smiler

Martin - Thanks a million for all your help and you are a rockstar Smiler Your knowledge is vast and incredible!!

Once again thanks for all the help!

Regards,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
 
Posts: 270 | Registered: October 30, 2014Reply With QuoteReport This Post
Platinum Member
posted Hide Post
quote:
for DEFINE and COMPUTE

I not suggest dynamic reformat, only DEFINE and COMPUTE.

Kofi


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
 
Posts: 103 | Registered: April 06, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
Seems to me that if you want to use ATODBL, and there is a % in it, just strip out the %.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6136 | Location: 33.8688° S, 151.2093° E | Registered: October 31, 2006Reply With QuoteReport This Post
Guru
posted Hide Post
Hi,

Sure Kofi and Waz...I will use your techniques as well!

Thanks a lot once again for looking into this Smiler

Regards,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
 
Posts: 270 | Registered: October 30, 2014Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]Alpha to numeric format

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.