Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

custum date dimension category in script 1

Status
Not open for further replies.

kikkerkermit

Programmer
Nov 13, 2005
7
NL
Dear experts,

I want to get a custom date dimension category with a script. De name of the dimension is 'Huidige periode' and its type is custom. The custom dimension is within the date dimension "Tijd(Boekingsdatum)".

Does somenone know how to achieve this ??

My thank will be great

Maarten van Eck

Sub Main ()

Dim Curdate as string
Dim objTransApp As Object
Dim objModel As Object
Dim objDateDim As Object
Dim objDateLevel As Object
Dim strLocation As String
Dim strModelSource As String
Dim strModelPath As String
strLocation = "D:\COGNOS\RETAIL\Delicontrol\Financieel\Powerplay\Model\" 'where you keep your models
strModelSource = "financieel.pyi" ' model name and type
strModelPath = strLocation & strModelSource

Set objTransApp = CreateObject("CognosTransformer.Application")

Set objModel = objTransApp.OpenModel(strModelPath)
Set objDateDim = objModel.Dimensions("Tijd(Boekingsdatum)")

'Here goes it wrong
Curdate = objDatedim.item("huidige periode").name


MsgBox "Current Period:" + Curdate


Set objDateLevel = Nothing
Set objDateDim = Nothing
Set objModel = Nothing
Set objTransApp = Nothing

End Sub
 
Maarten
You need to find the Category code of the special category from the model (right click in category view and select 'properties'. Then you can script to change it.

This snippet sets the name and scope of a special category to reflect the date of the last full calendar year
Code:
Set objDimension = objModel.Dimensions.Item("All Dates") 
   Set objCategory = objDimension.Categories(1)
   With objCategory
     .Code = "197499"
     .Name = "Calendar Year" & str(year(Cvar(date))-1)
     .Rollup = True
     .RunningPeriods = 12
     .TargetLevel = "Month"
     .TargetOffset = 0 - month(cvar(date)-1) 
     .Update
   End With

soi la, soi carré
 
Dear drlex,

thanks for your answer. But i still have the problem
how to pass the value of the custom dimension "huidige periode" to the variabele currdate.

Do you know how to do that ?

Is it something like this:

Set objModel = objTransApp.OpenModel(strModelPath)
Set objDateDim = objModel.Dimensions.item("Tijd(Boekingsdatum)")
Set objCategories = objDimension.Categories.code = "197499"

'197499 stands for huidige periode

Curdate = objCategories.name

MsgBox "Current Period:" + Curdate




Thank you very m,uch.
 
Maarten,
Ah, now I follow - you want to get the value of the latest date.
If so , you can use the currentperiod function on the date dimension.
Code:
Set objDimension = objModel.Dimensions("All Dates")
   MsgBox "Current Period:" + objDimension.CurrentPeriod.Name
This is in the format of the lowest level in the date dimension.

I believe that if you want the value of a special category, you'll need to open a powerplay report against the cube and "read in" the value displayed.

I think this is the only way, as a quick look at special date category in an mdl version of a model shows that the value of the category is not retained, just a lastuse date.

soi la, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top