Page 1 of 1

Lengthyness of the code

Posted: Wed Aug 10, 2016 10:58 am
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)))))))));

Re: Lengthyness of the code

Posted: Wed Aug 10, 2016 11:10 am
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'));

Re: Lengthyness of the code

Posted: Wed Aug 10, 2016 11:27 am
by Abhi30
thank you for your suggestion sir,

but i tried that
it gives error i think something went wrong.

Re: Lengthyness of the code

Posted: Wed Aug 10, 2016 11:43 am
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.

Re: Lengthyness of the code

Posted: Wed Aug 10, 2016 12:01 pm
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.

Re: Lengthyness of the code

Posted: Wed Aug 10, 2016 1:17 pm
by Abhi30
Yeah Sure Sir..

But how we can attach screen shot with messages in forum???

Re: Lengthyness of the code

Posted: Wed Aug 10, 2016 1:37 pm
by qml
Abhi30 wrote:But how we can attach screen shot with messages in forum???
Attachments.JPG
Attachments.JPG (18.63 KiB) Viewed 4203 times