TI referencing variables not in data source
-
- Regular Participant
- Posts: 194
- Joined: Thu May 30, 2013 1:41 pm
- OLAP Product: Cognos
- Version: Planning Analytics 2.0.7
- Excel Version: 2010
TI referencing variables not in data source
Hi,
I'm trying to use TI to break down monthly budget into weekly budget. I built a cube to store the number of days in a week that belongs to a certain month. For example: If the week begins Sunday, then there will be 4 days in the week of Jun 27th to July 3rd that belong to June and 3 days belong July.
3 cubes are involved.
Cube 1: Monthly Budget
Dimension 1: Year
Dimension 2: Month
Dimension 3: Sales $
Cube 2: Number of days in week
Dimension 1: Year
Dimension 2: Month
Dimension 3: Week
Dimension 4: Number of days
Cube 3: Weekly Budget
Dimension 1: Year
Dimension 2: Month
Dimension 3: Week
Dimension 4: Sales $
I have been using rules to send the monthly budget data in Cube 1 to Cube 3 via the allocation data in Cube 2 without problem.
Now I want to convert it into TI. However since the data source (Cube 1) does not have week as dimension I don't know how I can setup CellPutN to refer to the number of days stored in Cube 2.
Any advice is appreciated.
Kenneth
I'm trying to use TI to break down monthly budget into weekly budget. I built a cube to store the number of days in a week that belongs to a certain month. For example: If the week begins Sunday, then there will be 4 days in the week of Jun 27th to July 3rd that belong to June and 3 days belong July.
3 cubes are involved.
Cube 1: Monthly Budget
Dimension 1: Year
Dimension 2: Month
Dimension 3: Sales $
Cube 2: Number of days in week
Dimension 1: Year
Dimension 2: Month
Dimension 3: Week
Dimension 4: Number of days
Cube 3: Weekly Budget
Dimension 1: Year
Dimension 2: Month
Dimension 3: Week
Dimension 4: Sales $
I have been using rules to send the monthly budget data in Cube 1 to Cube 3 via the allocation data in Cube 2 without problem.
Now I want to convert it into TI. However since the data source (Cube 1) does not have week as dimension I don't know how I can setup CellPutN to refer to the number of days stored in Cube 2.
Any advice is appreciated.
Kenneth
Last edited by kenship on Tue Jun 22, 2021 6:53 pm, edited 1 time in total.
-
- MVP
- Posts: 3233
- 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: TI referencing variables not in data source
To refer to a cube, wouldn't it be CellGetN rather than CellPutN ?
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
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
-
- Regular Participant
- Posts: 194
- Joined: Thu May 30, 2013 1:41 pm
- OLAP Product: Cognos
- Version: Planning Analytics 2.0.7
- Excel Version: 2010
Re: TI referencing variables not in data source
Dear Wim,
Allow me to clarify using an example.
Cube 1: Monthly Budget
Year = 2021
Month = June
Sales $ = 100
Cube 2: Number of days in week
Year = 2021
Month = June
Week = 23, 24, 25, 26, 27
Number of days = 4 (week 23), 7 (week 24-26), 5 (week 27)
Cube 3: Weekly budget
Year = 2021
Month = June
Week = 23, 24, 25, 26, 27
Sales $:
week 23, June's portion would be 4 days/30 days * $100 =$13.33, plus May's portion
week 24-26, 7 days/30 days * 3 weeks * $100 = $70
week 27, 5 days / 30 days * $100 =$16.67, plus July's portion
Total June = $100
Since I use Cube 1 as my data source, I don't know how to set variables for week for reference to Cube 2 to get the number of days correctly to calculate the right amount and put into Cube 3.
Allow me to clarify using an example.
Cube 1: Monthly Budget
Year = 2021
Month = June
Sales $ = 100
Cube 2: Number of days in week
Year = 2021
Month = June
Week = 23, 24, 25, 26, 27
Number of days = 4 (week 23), 7 (week 24-26), 5 (week 27)
Cube 3: Weekly budget
Year = 2021
Month = June
Week = 23, 24, 25, 26, 27
Sales $:
week 23, June's portion would be 4 days/30 days * $100 =$13.33, plus May's portion
week 24-26, 7 days/30 days * 3 weeks * $100 = $70
week 27, 5 days / 30 days * $100 =$16.67, plus July's portion
Total June = $100
Since I use Cube 1 as my data source, I don't know how to set variables for week for reference to Cube 2 to get the number of days correctly to calculate the right amount and put into Cube 3.
Wim Gielis wrote: ↑Tue Jun 22, 2021 6:47 pm To refer to a cube, wouldn't it be CellGetN rather than CellPutN ?
-
- MVP
- Posts: 1828
- 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: TI referencing variables not in data source
You need to do some form of loop on the data tab where you loop through the weeks dimension.
The most basic form of this would be to simply loop the entire dimension e.g.
That most basic form may be fast enough... assuming you are looping though 52/53 weeks its pretty much nothing.
But it is for every single record, so checking 47 redundant weeks for every record can be a time waster.
In that case you can get smarter and do the processing earlier.
On your prolog tab do loops just of cube 2 and create temp subsets containing the weeks that are needed.
Then on your data tab you can just use the below to find the weeks that belong to a month:
Or if you are happy to have some persistent subsets hanging around you can just create them once when you populate cube 2... assuming that the data in cube 2 doesn't have to change that often. Which it shouldn't.
The most basic form of this would be to simply loop the entire dimension e.g.
Code: Select all
iCount = 1;
iMax = DimSiz ( cDimWeek );
While ( iCount <= iMax );
sWeek = DimNm ( cDimWeek, iCount );
If ( DType ( cDimWeek, sWeek ) @= 'N' & CellGetN ( Cube2, vsYear, vsMonth, sWeek, 'Number of Days' ) > 0 );
nValue = vnValue * ( CellGetN ( 'Cube2', vsYear, vsMonth, sWeek, 'Number of Days' ) \ 7 );
CellPutN ( nValue, 'Cube3', vsYear, vsMonth, vsWeek, 'Sales $' );
EndIf;
iCount = iCount + 1;
End;
But it is for every single record, so checking 47 redundant weeks for every record can be a time waster.
In that case you can get smarter and do the processing earlier.
On your prolog tab do loops just of cube 2 and create temp subsets containing the weeks that are needed.
Code: Select all
iYearCount = 1;
iYearMax = DimSiz ( cDimYear );
While ( iYearCount <= iYearMax );
sYear = DimNm ( cDimYear, iYearCount );
If ( DType ( cDimYear, sYear ) @= 'N' );
iMonthCount = 1;
iMonthMax = DimSiz ( cDimMonth );
While ( iMonthCount <= iMonthMax );
sMonth = DimNm ( cDimMonth, iMonthCount );
If ( Dtype ( cDimMonth, sMonth ) @= 'N' );
sSubsetName = sYear | '_' | sMonth;
SubsetCreate ( cDimWeek, sSubsetName, 1 );
iWeekCount = 1;
iWeekMax = DimSiz ( cDimWeek );
While ( iWeekCount <= iWeekMax );
sWeek = DimNm ( cDimWeek, iWeekCount );
If ( Dtype ( cDimWeek, sWeek ) @= 'N' & CellGetN ( Cube2, sYear, sMonth, sWeek, 'Number of Days' ) > 0 );
SubsetElementInsert ( cDimWeek, sSubsetName, sWeek, 1 );
EndIf;
iWeekCount = iWeekCount + 1;
End;
EndIf;
iMonthCount = iMonthCount + 1;
End;
EndIf;
IyearCount = iYearCount + 1;
End;
Code: Select all
iCount = 1;
iMax = SubsetGetSize ( cDimWeek, vsYear | '_' | vsMonth );
While ( iCount <= iMax );
sWeek = SubsetGetElementName ( cDimWeek, vsYear | '_' | vsMonth, iCount );
### do your stuff here
iCount = iCount + 1;
End;
Declan Rodger
-
- Regular Participant
- Posts: 194
- Joined: Thu May 30, 2013 1:41 pm
- OLAP Product: Cognos
- Version: Planning Analytics 2.0.7
- Excel Version: 2010
Re: TI referencing variables not in data source
Yeah I was trying to avoid doing a loop.
However, say I save a subset in Cube 2 which includes Year 2021, months 1-12, weeks 1-53 and the number of days, how would I include it in the TI and have it looked up correctly since I don't have the week as variable?
Kenneth
I'll give some thoughts to
However, say I save a subset in Cube 2 which includes Year 2021, months 1-12, weeks 1-53 and the number of days, how would I include it in the TI and have it looked up correctly since I don't have the week as variable?
Kenneth
I'll give some thoughts to
declanr wrote: ↑Tue Jun 22, 2021 7:05 pm You need to do some form of loop on the data tab where you loop through the weeks dimension.
The most basic form of this would be to simply loop the entire dimension e.g.That most basic form may be fast enough... assuming you are looping though 52/53 weeks its pretty much nothing.Code: Select all
iCount = 1; iMax = DimSiz ( cDimWeek ); While ( iCount <= iMax ); sWeek = DimNm ( cDimWeek, iCount ); If ( DType ( cDimWeek, sWeek ) @= 'N' & CellGetN ( Cube2, vsYear, vsMonth, sWeek, 'Number of Days' ) > 0 ); nValue = vnValue * ( CellGetN ( 'Cube2', vsYear, vsMonth, sWeek, 'Number of Days' ) \ 7 ); CellPutN ( nValue, 'Cube3', vsYear, vsMonth, vsWeek, 'Sales $' ); EndIf; iCount = iCount + 1; End;
But it is for every single record, so checking 47 redundant weeks for every record can be a time waster.
In that case you can get smarter and do the processing earlier.
On your prolog tab do loops just of cube 2 and create temp subsets containing the weeks that are needed.
Then on your data tab you can just use the below to find the weeks that belong to a month:Code: Select all
iYearCount = 1; iYearMax = DimSiz ( cDimYear ); While ( iYearCount <= iYearMax ); sYear = DimNm ( cDimYear, iYearCount ); If ( DType ( cDimYear, sYear ) @= 'N' ); iMonthCount = 1; iMonthMax = DimSiz ( cDimMonth ); While ( iMonthCount <= iMonthMax ); sMonth = DimNm ( cDimMonth, iMonthCount ); If ( Dtype ( cDimMonth, sMonth ) @= 'N' ); sSubsetName = sYear | '_' | sMonth; SubsetCreate ( cDimWeek, sSubsetName, 1 ); iWeekCount = 1; iWeekMax = DimSiz ( cDimWeek ); While ( iWeekCount <= iWeekMax ); sWeek = DimNm ( cDimWeek, iWeekCount ); If ( Dtype ( cDimWeek, sWeek ) @= 'N' & CellGetN ( Cube2, sYear, sMonth, sWeek, 'Number of Days' ) > 0 ); SubsetElementInsert ( cDimWeek, sSubsetName, sWeek, 1 ); EndIf; iWeekCount = iWeekCount + 1; End; EndIf; iMonthCount = iMonthCount + 1; End; EndIf; IyearCount = iYearCount + 1; End;
Or if you are happy to have some persistent subsets hanging around you can just create them once when you populate cube 2... assuming that the data in cube 2 doesn't have to change that often. Which it shouldn't.Code: Select all
iCount = 1; iMax = SubsetGetSize ( cDimWeek, vsYear | '_' | vsMonth ); While ( iCount <= iMax ); sWeek = SubsetGetElementName ( cDimWeek, vsYear | '_' | vsMonth, iCount ); ### do your stuff here iCount = iCount + 1; End;
-
- MVP
- Posts: 3233
- 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: TI referencing variables not in data source
Declan showed you how to create and populate subsets. Each subset contains the year and the month in its name.
Wouldn't that be an option for referencing the subset and loop through its elements ?
Wouldn't that be an option for referencing the subset and loop through its elements ?
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
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
-
- Regular Participant
- Posts: 227
- Joined: Wed May 06, 2020 2:58 pm
- OLAP Product: Planning Analytics
- Version: 2.0.9
- Excel Version: 2016
Re: TI referencing variables not in data source
You could create a dimension that could be used for a lookup. Why not have a dimension like this
2021 > Jan 2021 > Week 1 2021
Then when you're doing the push from cube 1 to 3 you can loop through only the weeks required aka children of Jan 2021 instead of the whole year. Also gives you the option to run the process by month then
Also if its structured like this you can move weeks around without amending other years rather then just calling it week 1, which may belong to Jan one year but maybe Apr in another. (particularly if changing financial years)
2021 > Jan 2021 > Week 1 2021
Then when you're doing the push from cube 1 to 3 you can loop through only the weeks required aka children of Jan 2021 instead of the whole year. Also gives you the option to run the process by month then
Also if its structured like this you can move weeks around without amending other years rather then just calling it week 1, which may belong to Jan one year but maybe Apr in another. (particularly if changing financial years)
-
- MVP
- Posts: 1828
- 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: TI referencing variables not in data source
Why do you want to avoid doing a loop?
I would say that for this sort of thing a loop be it on a dimension, subset, or "lookup dimension" (as per Burnstripe's comment) is *almost* essential - and very likely the most efficient way of doing it.
There are other options that wouldn't involve a loop but I wouldn't do them personally e.g.:
1/ You prepopulate Cube 3 with number of days in one TI process. You can have a second TI process that transfers values from Cube 1 with a CellPutProportionalSpread. You would need to decide how to exclude populating number of days where there would be no value to transfer in the end.
This would likely be very inefficient.
2/ Depending how big Cube 3 is, you can just have a Process that has Cube 3 as its datasource. Set to not skip zeroes. Then for each cell, it checks against Cube 1 and 2 to decide what value it should have.
This would be inefficient BUT if the cube is small enough it could still be fast.
Declan Rodger
-
- Regular Participant
- Posts: 194
- Joined: Thu May 30, 2013 1:41 pm
- OLAP Product: Cognos
- Version: Planning Analytics 2.0.7
- Excel Version: 2010
Re: TI referencing variables not in data source
Hi all,
I haven't started working on it yet but will do today or tomorrow. Thanks to all for the advice.
Kenneth
I haven't started working on it yet but will do today or tomorrow. Thanks to all for the advice.
Kenneth