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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to update measure lable - Transformer/Scripting

Status
Not open for further replies.

spicysudhi

Programmer
Nov 10, 2003
575
FR
hi

below is my code. I am trying to update a measure in the model with some different label. Actually, the measure lable needs to be different every month, so I thought of updating everymonth before cube building. The code returns no errors, but the cube generated is not having the new lable or model is not updated with the new label.

============
Dim objTransApp As CognosTransformer.Application
Dim objModel As CognosTransformer.Model
Dim objMeasure As New CognosTransformer.Measure

Set objTransApp = New CognosTransformer.Application
Set objModel = objTransApp.OpenModel("D:\test.pyi")
Set objMeasure = objModel.Measures("Qty")

objMeasure.Label = "Qty May-04"
objModel.Update
objModel.Save
objModel.Close

=====================

the requirement is something like the lable on the measure should be current month-name + some description (say Qty). In the above example, I am trying to update the measure "Qty" with label "Qty May-04" so that in cube it displays as "Qty May-04" and not as just Qty.

can anyone help me here...

thanks,
Sudhi
 
or anybody got a script that updates/amends the transformer model file?
(for me it looks like objModel.Save or objModel.saveAs or .update methods doesnot seems to be updating the changes!!)
 
sudhi,
An example shown in the help file for Label property of Measures has an Update for objMeasure.
An extract of the relevant section follows:
Code:
   Set objMeasure = objModel.Measures.Item("Cost")

   With objMeasure

      .Format "$#,##0"

      .Label = "Product Cost"

      .MissingValue = trMissingValueNA

      .ShortName = "Item Cost"

      .Update

   End With
Perhaps you need to modify your code to this format or put an 'objMeasure.Update' line in.
just a thought,
lex

soi la, soi carre
 
Why not name your measure Qty Current Month?

Pain is stress leaving the body.

DoubleD [bigcheeks]
 
thanks lex. I noticed .update missing in my statements.
doubleD, i got a 12 measures (for one year) so, current month, cur.month+1 or next month like that doesnt make much sense to users...

thanks
sudhi
 
sudhi,
you're welcome. A thought occurs to me - if you change the measure label and the cube is being accessed via PPES, will it not cause a cross-tab error on existing reports after cube update? I've had this problem when making what I thought were only cosmetic changes to cube models.
lex


soi la, soi carre
 
well, I am not facing that problem as of now. I updated the cube twice, labels changed, but the reports created earlier are woking fine. i think unless we change the name, it should be ok.
 
Good to hear it's not a problem; I may consider doing likewise to assist users. Shame a dynamic label can't be set in the model to avoid the need for scripting. Perhaps 7.2 might bring such?
Happy Friday,
lex

soi la, soi carre
 
I'm assuming you're already using a time dimension in your cube, could you give a little background about your cube and why you chose to design it with a measure for each month?

Pain is stress leaving the body.

DoubleD [bigcheeks]
 
We have data like this

Month (Time)
Forecast Month0
Forecast Month1
Forecast Month2
....
Forecast Month12


everymonth, we have next 12 months records.

regards,
Sudhi

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top