Concatenate multiple variables

Post Reply
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Concatenate multiple variables

Post by ViRa »

Hi,

I'm trying to concatenate the variables that make up address. With the syntax I'm using, the variables appear in a row separated by space as shown in the code below. However, I want them to appear one below other (like an address would generally appear). Could you please guide me on how to do this?

Thanks for your time and help.

Code: Select all

vProviderDetails = Provider_Address |' ' | Provider_City |' '| Provider_State |' '| Provider_Zipcode;
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: Concatenate multiple variables

Post by tomok »

ViRa wrote:Hi,

I'm trying to concatenate the variables that make up address. With the syntax I'm using, the variables appear in a row separated by space as shown in the code below. However, I want them to appear one below other (like an address would generally appear). Could you please guide me on how to do this?

Thanks for your time and help.

Code: Select all

vProviderDetails = Provider_Address |' ' | Provider_City |' '| Provider_State |' '| Provider_Zipcode;
What you need is to add the carriage return ASCII code (015) after each variable.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: Concatenate multiple variables

Post by ViRa »

Thanks Tom,

I looked up for carriage return ASCII code (015) and found it to be SI. You mean I should add SI after every variable? Please correct me. Thanks again.
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: Concatenate multiple variables

Post by ViRa »

Sorry, Carriage Return code is CR. But could you please guide me on how to add it after each variable?
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Concatenate multiple variables

Post by Alan Kirk »

ViRa wrote:Sorry, Carriage Return code is CR. But could you please guide me on how to add it after each variable?
Tomok actually gave you the Octal rather than decimal code for a CR; it's 10 in decimal. You can add that by using the CHAR() rules function. Your code would therefore become:

Code: Select all

vProviderDetails = Provider_Address | CHAR(10) | Provider_City |CHAR(10) | Provider_State |CHAR(10) | Provider_Zipcode;
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: Concatenate multiple variables

Post by ViRa »

Thanks Alan.

I tried the code but the address still appears to be in a single row when viewed in Cube or sliced to Excel. Is it how it would appear in Cube view or Excel? Please advise.
10 is for line feed and 13 is carriage return. Should I use a combination of both in order for each variable to appear one below other? Thanks for your time.
lotsaram
MVP
Posts: 3706
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Concatenate multiple variables

Post by lotsaram »

ViRa wrote:Thanks Alan.

I tried the code but the address still appears to be in a single row when viewed in Cube or sliced to Excel. Is it how it would appear in Cube view or Excel? Please advise.
10 is for line feed and 13 is carriage return. Should I use a combination of both in order for each variable to appear one below other? Thanks for your time.
I do not understand. Surely the effort to type out your post is already the equivalent of just trying this out for yourself. Just do it already.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: Concatenate multiple variables

Post by ViRa »

Hi lotsaram,

I had asked guidance to concatenate multiple variables with each variable appearing one below other in order to make an address in TI formula window. As per Tom and Alan's suggestion, I have to insert the Carriage Return ASCII Code along with the CHAR function. But when I used the code that Alan suggested, the variables were appearing in a single row when viewed in Cube or sliced to Excel (as it would if I had concatenated using a space instead of Carriage Return ASCII Code). I googled and found that code 10 is for Line Feed and 13 is for Carriage Return. So I want to know now if I have to use a combination of both these code in order for the variables to appear one below other.

Eg, Currently the variables appear as below -

13th South Street New York NY 1001

But my requirement is as below -

13th South Street
New York
NY 1001

Hope I was able to explain myself clearly this time.
declanr
MVP
Posts: 1831
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: Concatenate multiple variables

Post by declanr »

From memory CHAR(13) works when displayed through a slice or snapshot but not in active forms.
I can't recall ever looking at it directly in a cube viewer but would be very surprised if that ever worked.

But to elaborate on Lotsa's point, you had already provided the basis for what you wanted to try, he was suggesting it would have been quicker for you to write that code, run the TI and check the results than it would have been to post here and wait for a response.
Declan Rodger
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: Concatenate multiple variables

Post by ViRa »

Thanks Declan.

I understand Lotsaram's point now

Well, all this while I did try various combinations instead of just waiting for a response, such as - CHAR (10) only, or CHAR (13) only. But both resulted in same output. When I tried the combination of ASCII codes it did throw error as expected. So I was wondering if there is a syntax in case I have to use two ASCII codes.
declanr
MVP
Posts: 1831
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: Concatenate multiple variables

Post by declanr »

ViRa wrote:Well, all this while I did try various combinations instead of just waiting for a response, such as - CHAR (10) only, or CHAR (13) only. But both resulted in same output.
Were you only checking the results in the cube viewer as opposed to in slices etc? You need to remember that the cube viewer is really more of a system object than a presentation layer (even though we sometimes use it that way.)

ViRa wrote:When I tried the combination of ASCII codes it did throw error as expected. So I was wondering if there is a syntax in case I have to use two ASCII codes.
How did you try and combine them?
A concatenation should work as it would any other way e.g.

Code: Select all

CHAR(10) | CHAR(13)
I don't see much benefit in combining them though.
Declan Rodger
lotsaram
MVP
Posts: 3706
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Concatenate multiple variables

Post by lotsaram »

How thorough is your testing? My guess is "not very".

Line feed Char(10) works fine as a line feed separator for strings stored in TM1 cubes for display on separate lines in Excel. Note that you do have to make sure that the wrap text property of the cells is set to true. Whether this is handled correctly in websheets I don't know but you would be welcome to test and let us know the result.

I don't think there is anything you can do about line wrapping in the cube viewer though, but the cube viewer is hardly a viewing interface for text data anyway. As Declan said, there wouldn't be much point combining the characters.

What you haven't said is what the display interface for users actually is. You can actually store rich text or markup in TM1 string cells. It will only display as plain text within TM1 but if you put a UI between the text and the user to handle text display and input then then it is possible to do a lot more with text intensive applications in TM1 than what has typically been done.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: Concatenate multiple variables

Post by ViRa »

Thanks Declan and Lotsaram.

Declan, thanks for letting me know the correct way to concatenate multiple ASCII codes. I was definitely not using the syntax as yours and hence the error.

Lotsaram, I used the Line Feed code (10) only this time and tested the results in Cube View as well as Excel. Cube View displays the result in a single line and Declan's explanation to it being a system object than a presentation layer makes sense to me. On slicing to excel and Active Form, the address shows in a single line. Snapshot to Excel and ISB shows the result as I desired, i.e. variables are displayed one below the other.

Since the cube is being built for demo purpose, the users have not asked for any display interface in particular. I intend to use ISB for demo though.

Thanks again for your help.
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: Concatenate multiple variables

Post by tomok »

Whether or not your thing is going to work is entirely dependent on whether the particular interface you are using supports the carriage return/line feed. It appears, not surprisingly, that the cube viewer does not. I know for a fact that Excel formulas do not unless you format the cell for line wrapping, this is why a slice or active form report doesn't work. This is easy to test. Simply type text in cell A1 and add a carriage return/line feed (by hitting Alt-Enter) and then typing in more text. The text wraps. Now go to another cell and make the formula be =A1. You'll see the text from A1 but the line wrap will be gone. Now format the cell for line wrapping and it's back.

Let me just add at this point that your exercise is a bad idea. Why? Because you are making your users think that wrapping the address is going to work in TM1 and it's not. It's ONLY going to work in an Excel-based report. It's better to be honest with your users up front. Don't be afraid to tell them something isn't going to work, it's not a reflection on you. It's only a reflection on you when you tell them something is going to work and it does not.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: Concatenate multiple variables

Post by ViRa »

Thanks Tom for your advice. I will present the actual functionality in the demo rather than manipulating the variables (unless specifically asked for). This post helped me learn a new concept of concatenating variables which I always wanted to know. Also, I performed the test you suggested and now I understand it better. I enabled the wrap text feature and Active form as well as Slice now wraps the address as required.
Post Reply