Do I need to / how do I concatenate in rule

Post Reply
User avatar
ADW
Posts: 32
Joined: Tue Jun 14, 2011 11:10 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2010
Location: Cheshire, England

Do I need to / how do I concatenate in rule

Post by ADW »

I have this feeder:

Code: Select all

['Effect'] => DB('Headcount Intermediate', 'Forecast', !Year, 
		           DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Effective AP'), 
		           !Cost Centre, 
		           DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Level'), 
		           !Heacount Position Number, 'TEST') ;

The 'Effective AP' part of the code will return a period 1 - 12 (numerical only), however the dimension it flows into (Month) contains AP 1 - AP 12 (text). How can I append "AP" infront of DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Effective AP')? Month number (1 - 12) is an attribute of Month so does it even need AP putting on the front??
Catherine
Posts: 110
Joined: Wed May 20, 2009 7:30 am
OLAP Product: TM1
Version: 10.2.2 - PA
Excel Version: 2010
Location: Rennes, France

Re: Do I need to / how do I concatenate in rule

Post by Catherine »

Hi,

To append "AP" infront of DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Effective AP'), you have to write it this way:

'AP ' | DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Effective AP')
User avatar
qml
MVP
Posts: 1096
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: Do I need to / how do I concatenate in rule

Post by qml »

Use the pipe (|) to concatenate strings like below (note it would also work without getting the spaces right by using TRIM, but I like to keep things looking clean). If 'Effective AP' is a numeric measure, you also need to convert the value to a string using STR.

Code: Select all

['Effect'] => DB('Headcount Intermediate', 'Forecast', !Year, 
		           'AP ' | TRIM( STR( DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Effective AP'), 2, 0)), 
		           !Cost Centre, 
		           DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Level'), 
		           !Heacount Position Number, 'TEST') ;
If month number is just a numeric attribute of month (an not an alias) then you can't use it to reference the elements in a feeder statement. If it's an alias, you can use them like there were normal element names.
Kamil Arendt
Duncan P
MVP
Posts: 600
Joined: Wed Aug 17, 2011 1:19 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2
Excel Version: 2003 2007
Location: York, UK

Re: Do I need to / how do I concatenate in rule

Post by Duncan P »

It's in the documentation but I remember also finding it difficult to locate. It doesn't appear to be in the "Reference" but I did find it squirreled away at the end of the "Syntax for Formulas"[sic] section of the "Developer Guide" (together with an example which is just plain wrong).
User avatar
ADW
Posts: 32
Joined: Tue Jun 14, 2011 11:10 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2010
Location: Cheshire, England

Re: Do I need to / how do I concatenate in rule

Post by ADW »

Thanks for you replies. I had the pipe seperator but not the convert to string. I will give that a go.

Cheers.
User avatar
ADW
Posts: 32
Joined: Tue Jun 14, 2011 11:10 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2010
Location: Cheshire, England

Re: Do I need to / how do I concatenate in rule

Post by ADW »

That works as it should now. Thanks.

I now have a different issue. I need the feeder to feed to all APs equal to or larger than 'Effective AP'.

Code: Select all

['Effect'] => DB('Headcount Intermediate', 'Forecast', !Year, 
		           'AP' | TRIM( STR( DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Effective AP'), 2, 0 )),
		           !Cost Centre, 
		           DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Level'), 
		           !Heacount Position Number, 'TEST') ;
User avatar
qml
MVP
Posts: 1096
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: Do I need to / how do I concatenate in rule

Post by qml »

ADW wrote:I now have a different issue. I need the feeder to feed to all APs equal to or larger than 'Effective AP'.
The easiest way would be to create a set of Year-to-Go consolidations in the AP dimension similar to this (adjust the naming convention to whatever you think best):
  • AP 1 YTG
    AP 1
    AP 2
    AP 3
    AP 4
    AP 5
    AP 6
    AP 7
    AP 8
    AP 9
    AP 10
    AP 11
    AP 12
  • AP 2 YTG
    AP 2
    AP 3
    AP 4
    AP 5
    AP 6
    AP 7
    AP 8
    AP 9
    AP 10
    AP 11
    AP 12
  • AP 3 YTG
    AP 3
    AP 4
    AP 5
    AP 6
    AP 7
    AP 8
    AP 9
    AP 10
    AP 11
    AP 12
etc until "AP 12 YTG".

Then you can just slightly amend your feeder statement to feed the right one of these consolidations (which is shorthand for feeding their children) to get the desired effect.

Code: Select all

['Effect'] => DB('Headcount Intermediate', 'Forecast', !Year, 
                 'AP' | TRIM( STR( DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Effective AP'), 2, 0 )) | ' YTG',
                 !Cost Centre, 
                 DB('Headcount Adjustments', !Year, !Cost Centre, !Heacount Position Number, 'Level'), 
                 !Heacount Position Number, 'TEST');
Kamil Arendt
User avatar
ADW
Posts: 32
Joined: Tue Jun 14, 2011 11:10 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2010
Location: Cheshire, England

Re: Do I need to / how do I concatenate in rule

Post by ADW »

Thanks for that. I think we're almost there now!!!

Last issue (hopefully).

In the destination cube the start month is being fed but the months after are not. They appear but do not consolidate. (I have a feeling that didn't make sense so I've added a picture)
Dest cube view.png
Dest cube view.png (9.63 KiB) Viewed 12871 times
User avatar
ADW
Posts: 32
Joined: Tue Jun 14, 2011 11:10 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2010
Location: Cheshire, England

Re: Do I need to / how do I concatenate in rule

Post by ADW »

It's OK. Done it now.

Had a space missing between AP and the number....Doh!! :lol:
User avatar
Steve Rowe
Site Admin
Posts: 2455
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Do I need to / how do I concatenate in rule

Post by Steve Rowe »

Are you sure that was your issue? As far as I'm aware TM1 has never cared about spaces (or cases) in element names.
Have done a full restart of your environment since you finished writing your rules / feeders? This is the only 100% safe way to tell if you rules are working.
The feeder flags persist in the cube through repeated saves of the rule sheet, this means that when you save a rule sheet you have the feeders of the current rule set and the feeders of all previous rules saved since the last reboot.

This can lead to your code to stop working following a restart.
Cheers
Technical Director
www.infocat.co.uk
User avatar
ADW
Posts: 32
Joined: Tue Jun 14, 2011 11:10 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2010
Location: Cheshire, England

Re: Do I need to / how do I concatenate in rule

Post by ADW »

Not sure how things should work but that space makes all the difference. Took the space out and restarted the server, feeder doesn't work as I want it to, put the space back in and everything is fine again!
User avatar
Steve Rowe
Site Admin
Posts: 2455
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Do I need to / how do I concatenate in rule

Post by Steve Rowe »

Interesting, would you mind posting the different flavours of the rule highlighting where the space is?
Cheers
Technical Director
www.infocat.co.uk
User avatar
ADW
Posts: 32
Joined: Tue Jun 14, 2011 11:10 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2010
Location: Cheshire, England

Re: Do I need to / how do I concatenate in rule

Post by ADW »

hmmm...I may need to retract my claim. The feeder rule works for an extra month each time I press save...I don't get it...
Post Reply