Lengthyness of the code

Post Reply
Abhi30
Posts: 11
Joined: Mon Aug 08, 2016 1:45 pm
OLAP Product: Ibm Cognos
Version: 10.2.2
Excel Version: 2016
Location: Mumbai

Lengthyness of the code

Post by Abhi30 »

hello all..,

how can i reduce the code ???
it gets too lengthy if i want to write it for 12 months??

['Travel Rate/Day' ] = N: IF(DB('2r_Hotel',!2a_Employee_Name,'Travel')@='Bus'& DB('2r_Hotel',!2a_Employee_Name,'Month Of Travel')@='Jan',DB('2r_Hotel_Expenses', 'Jan','Bus'),IF(DB('2r_Hotel',!2a_Employee_Name,'Travel')@='Bus'& DB('2r_Hotel', !2a_Employe
e_Name, 'Month Of Travel')@='Feb',DB('2r_Hotel_Expenses', 'Feb','Bus'),IF(DB('2r_Hotel',!2a_Employee_Name,'Travel')@='Bus'& DB('2r_Hotel', !2a_Employee_Name, 'Month Of Travel')@='Mar',DB('2r_Hotel_Expenses', 'Mar','Bus'), IF(DB('2r_Hotel',!2a_Employee_Nam
e,'Travel')@='Air'& DB('2r_Hotel', !2a_Employee_Name, 'Month Of Travel')@='Jan',DB('2r_Hotel_Expenses','J
an', 'Air'),IF(DB('2r_Hotel',!2a_Employee_Name,'Travel')@='Air'& DB('2r_Hotel', !2a_Employee_Name, 'Month Of Travel')@='Feb',DB('2r_Hotel_Expenses', 'Feb', 'Air'),IF(DB('2r_Hotel',!2a_Employee_Name,'Travel')@='Air'& DB('2r_Hotel', !2a_Employee_Name, 'Mont
h Of Travel')@='Mar',DB('2r_Hotel_Expenses', 'Mar', 'Air'),IF(DB('2r_Hotel',!2a_Employee_Name,'Travel')@='Train'& DB('2r_Hotel', !2a_Employee_Name, 'Month Of Travel')@='Jan',DB('2r_Hotel_Expenses', 'Jan', 'Train'),IF(DB('2r_Hotel',!2a_Employee_Name,'Trave
l')@='Train'& DB('2r_Hotel', !2a_Employee_Name, 'Month Of Travel')@='Feb',DB('2r_Hotel_Expenses', 'Feb', 'Train'),IF(DB('2r_Hotel',!2a_Employee_Name,'Travel')@='Train'& DB('2r_Hotel', !2a_Employee_Name, 'Month Of Travel')@='Mar',DB('2r_Hotel_Expenses', 'M
ar', 'Train'),0)))))))));
Wim Gielis
MVP
Posts: 3234
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Lengthyness of the code

Post by Wim Gielis »

After your previous topic, I expected a question like this.
I suggested using DB() nested within DB(), like:

Code: Select all

['Travel Rate/Day' ] = N: DB('2r_Hotel_Expenses', DB('2r_Hotel',!2a_Employee_Name,'Month Of Travel'), DB('2r_Hotel',!2a_Employee_Name,'Travel'));
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Abhi30
Posts: 11
Joined: Mon Aug 08, 2016 1:45 pm
OLAP Product: Ibm Cognos
Version: 10.2.2
Excel Version: 2016
Location: Mumbai

Re: Lengthyness of the code

Post by Abhi30 »

thank you for your suggestion sir,

but i tried that
it gives error i think something went wrong.
Wim Gielis
MVP
Posts: 3234
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Lengthyness of the code

Post by Wim Gielis »

Abhi30 wrote:it gives error i think something went wrong.
That's a safe bet.

Please post the structure of the cubes, if you would like to have a solution.
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
Steve Rowe
Site Admin
Posts: 2456
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: Lengthyness of the code

Post by Steve Rowe »

Hi Abhi,

In order to get any further help on this please post, with screen shots, the dimensionality of all the cubes involved including the elements that are in the dimensions and views of the data in the cubes.

Then post the entire rule sheet for the cube where you have written the nested DB references as explained in both your posts.

Then explain what is going wrong, have you got an error, no value, the wrong value.

Once you do those things then we should be able to help you.
Technical Director
www.infocat.co.uk
Abhi30
Posts: 11
Joined: Mon Aug 08, 2016 1:45 pm
OLAP Product: Ibm Cognos
Version: 10.2.2
Excel Version: 2016
Location: Mumbai

Re: Lengthyness of the code

Post by Abhi30 »

Yeah Sure Sir..

But how we can attach screen shot with messages in forum???
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: Lengthyness of the code

Post by qml »

Abhi30 wrote:But how we can attach screen shot with messages in forum???
Attachments.JPG
Attachments.JPG (18.63 KiB) Viewed 4202 times
Kamil Arendt
Post Reply