Showing posts with label meas. Show all posts
Showing posts with label meas. Show all posts

Friday, February 24, 2012

AMO: how to get a SourceColumnName from a measure object?

Hi, friends, please look this:

In AMO, I can get a measure object:

Dim meas As Microsoft.AnalysisServices.Measure

meas = tDatabase.Cubes(0).MeasureGroups(0).Measures(0)

Dim dt as DataItem= meas.source

Now I want to find the meas' SourceColumnName, that is, the ColumnName of the measure mapped to.

But how? I tried the meas.source's property, but did not find anyone like a Name.

Please help me.

Thanks!

Hi there,

Try

tDatabase.Cubes(0).MeasureGroups(0).Measures(0).Source.Source.ToString()

C

|||

Thanks!|||

The source of a Measure can be either a:

1. ColumnBinding (the common case): this points (with the TableID and ColumnID properties) to a System.Data.DataColumn in the DataSourceView of the Cube (specified in the Cube.Source property). This DataColumn can be either a regular column or a calculated column, there are these special extended properties (in the DataColumn.ExtendedProperties collection) to consider: DbColumnName (provides the real column name in the relational table, this is usually the same with the DataColumn.ColumnName) and DbExpression (provides the SQL expression for a calculated column)

2. RowBinding: used for row count measures, points (with the TableID property) to the System.Data.DataTable in the DataSourceView

3. MeasureBinding: used for linked measures (in a linked measure group), points (with the MeasureID property) to the measure to link

Adrian Dumitrascu

|||

I am trying to , via AMO, get the type of Binding for a measure (column, row, measure) and then return, when the type is columnbinding, the columnid and tableid from the DSV. Could you provide an example?

AMO: how to get a SourceColumnName from a measure object?

Hi, friends, please look this:

In AMO, I can get a measure object:

Dim meas As Microsoft.AnalysisServices.Measure

meas = tDatabase.Cubes(0).MeasureGroups(0).Measures(0)

Dim dt as DataItem= meas.source

Now I want to find the meas' SourceColumnName, that is, the ColumnName of the measure mapped to.

But how? I tried the meas.source's property, but did not find anyone like a Name.

Please help me.

Thanks!

Hi there,

Try

tDatabase.Cubes(0).MeasureGroups(0).Measures(0).Source.Source.ToString()

C

|||

Thanks!|||

The source of a Measure can be either a:

1. ColumnBinding (the common case): this points (with the TableID and ColumnID properties) to a System.Data.DataColumn in the DataSourceView of the Cube (specified in the Cube.Source property). This DataColumn can be either a regular column or a calculated column, there are these special extended properties (in the DataColumn.ExtendedProperties collection) to consider: DbColumnName (provides the real column name in the relational table, this is usually the same with the DataColumn.ColumnName) and DbExpression (provides the SQL expression for a calculated column)

2. RowBinding: used for row count measures, points (with the TableID property) to the System.Data.DataTable in the DataSourceView

3. MeasureBinding: used for linked measures (in a linked measure group), points (with the MeasureID property) to the measure to link

Adrian Dumitrascu

|||

I am trying to , via AMO, get the type of Binding for a measure (column, row, measure) and then return, when the type is columnbinding, the columnid and tableid from the DSV. Could you provide an example?

AMO: About the measure object''s remove method.

hi,friend, please look this:

I have a measure object in AMO.

Dim meas As Microsoft.AnalysisServices.Measure
Meas =tDatabase.Cubes(0).MeasureGroups(0).Measures(0)

tDatabase.Cubes(0).MeasureGroups(0).Measures.Remove(Meas, True)

I just want to know the meaning of the Remove method's second para. Measures.Remove(item as Microsoft.AnalysisServices.Measure, CleanUp as boolean)

What's the CleanUP? The remove method also support to only use the item para. What happened if I set the CleanUP to True/False, or just missing it?

Thanks!

Hi,

The 'cleanUp' boolean argument specifies if the dependent objects will be removed. For a Measure, the dependents include the PerspectiveMeasure objects. For a DimensionAttribute, the dependents include the CubeAttribute objects.

If you do not specify the 'cleanUp' parameter, the dependents are removed.

If you want for example to replace one object with another (having the same ID), then you can use the 'cleanUp'=false argument.

When working connected to the server, the 'cleanUp' argument has limited use, because you cannot save an invalid object or an object that would invalidate other objects in the database. For example, if you chose to remove a Measure with 'cleanUp'=false and dependent PerspectiveMeasures do exist, then you will get an error when trying to save the MeasureGroup (because it will leave the Perspective(s) with broken references).

Adrian Dumitrascu

|||

Thank you very much, Adrian.

As you said,The 'cleanUp' boolean argument specifies if the dependent objects will be removed.

I want to konw, the KPI object is the dependent object to the Measure? When I remove a measure with CleanUp= True, will the KPI associated be removed too? Or Just I need to remove the KPI by myself? If I don't remove the KPI, but removed the measure which associated, will it report an error when I save it to the server?

Thanks again.

|||

> I want to konw, the KPI object is the dependent object to the Measure? When I remove a measure with CleanUp= True, will the KPI associated be removed too?

No, the KPI objects are not removed. If the Value property of the KPI is referring to a certain measure, when you delete that measure, AMO will not parse the Value (nor any Command objects from an MdxScript in the Cube, or other MDX fragments in other objects) to see if the measure is used.

When checking for dependents, AMO only sees direct-defined metadata references; for example: a PerspectiveMeasure has the MeasureID property to reference the Measure, a CubeAttribute has the AttributeID property to reference a DimensionAttribute, a CubeDimension has the DimensionID property to reference a Dimension.

> If I don't remove the KPI, but removed the measure which associated, will it report an error when I save it to the server?

The .Update() method will succeed (because the Analysis Services engine will do a similar dependencies analysis as AMO), but you will get MDX errors when browsing.

Adrian Dumitrascu

|||

very clear!

Thank you, Adrian!

AMO: About the measure object's remove method.

hi,friend, please look this:

I have a measure object in AMO.

Dim meas As Microsoft.AnalysisServices.Measure
Meas =tDatabase.Cubes(0).MeasureGroups(0).Measures(0)

tDatabase.Cubes(0).MeasureGroups(0).Measures.Remove(Meas, True)

I just want to know the meaning of the Remove method's second para. Measures.Remove(item as Microsoft.AnalysisServices.Measure, CleanUp as boolean)

What's the CleanUP? The remove method also support to only use the item para. What happened if I set the CleanUP to True/False, or just missing it?

Thanks!

Hi,

The 'cleanUp' boolean argument specifies if the dependent objects will be removed. For a Measure, the dependents include the PerspectiveMeasure objects. For a DimensionAttribute, the dependents include the CubeAttribute objects.

If you do not specify the 'cleanUp' parameter, the dependents are removed.

If you want for example to replace one object with another (having the same ID), then you can use the 'cleanUp'=false argument.

When working connected to the server, the 'cleanUp' argument has limited use, because you cannot save an invalid object or an object that would invalidate other objects in the database. For example, if you chose to remove a Measure with 'cleanUp'=false and dependent PerspectiveMeasures do exist, then you will get an error when trying to save the MeasureGroup (because it will leave the Perspective(s) with broken references).

Adrian Dumitrascu

|||

Thank you very much, Adrian.

As you said,The 'cleanUp' boolean argument specifies if the dependent objects will be removed.

I want to konw, the KPI object is the dependent object to the Measure? When I remove a measure with CleanUp= True, will the KPI associated be removed too? Or Just I need to remove the KPI by myself? If I don't remove the KPI, but removed the measure which associated, will it report an error when I save it to the server?

Thanks again.

|||

> I want to konw, the KPI object is the dependent object to the Measure? When I remove a measure with CleanUp= True, will the KPI associated be removed too?

No, the KPI objects are not removed. If the Value property of the KPI is referring to a certain measure, when you delete that measure, AMO will not parse the Value (nor any Command objects from an MdxScript in the Cube, or other MDX fragments in other objects) to see if the measure is used.

When checking for dependents, AMO only sees direct-defined metadata references; for example: a PerspectiveMeasure has the MeasureID property to reference the Measure, a CubeAttribute has the AttributeID property to reference a DimensionAttribute, a CubeDimension has the DimensionID property to reference a Dimension.

> If I don't remove the KPI, but removed the measure which associated, will it report an error when I save it to the server?

The .Update() method will succeed (because the Analysis Services engine will do a similar dependencies analysis as AMO), but you will get MDX errors when browsing.

Adrian Dumitrascu

|||

very clear!

Thank you, Adrian!