Showing posts with label dim. Show all posts
Showing posts with label dim. Show all posts

Saturday, February 25, 2012

AMO: list of cubes using a dim

Hello!

I'm trying to get a list of all cubes which are using a specific dimension with AMO. I could get a list of all cubes, then all dimensions used by each cube and check where my dimension is used but I feel there must be a more elegent solution ;-)
There is a GetReferences method in the Dimension object but I don't know how to use it, any idea or a better way to get my list ?

Other question: is there a way to automatically do a full or update process on each dim of a cube when we process this cube without having to list them all before ?

Thx!

I suggest to write the code that you mentioned: iterate over all Cubes and their CubeDimensions, checking which CubeDimension points to your Dimension. Because one Dimension can be included multiple times in a Cube (role-playing dimensions feature), you won't be able to use the cube.Dimensions.Contain(...) method (because that method is based on the ID of the CubeDimension which is not necessarily the same as the ID of the Dimension). When checking if a CubeDimension points to your Dimension, it's faster to compare the string IDs (CubeDimension.DimensionID with Dimension.ID, case insensitive compare), than to use the CubeDimension.Dimension property (because that does a lookup).

The GetReferences method will do the same iterations over all the Cubes and their CubeDimensions, plus more (so it won't be faster than your code).

Adrian

|||Thx for your help Adrian!

AMO: list of cubes using a dim

Hello!

I'm trying to get a list of all cubes which are using a specific dimension with AMO. I could get a list of all cubes, then all dimensions used by each cube and check where my dimension is used but I feel there must be a more elegent solution ;-)
There is a GetReferences method in the Dimension object but I don't know how to use it, any idea or a better way to get my list ?

Other question: is there a way to automatically do a full or update process on each dim of a cube when we process this cube without having to list them all before ?

Thx!

I suggest to write the code that you mentioned: iterate over all Cubes and their CubeDimensions, checking which CubeDimension points to your Dimension. Because one Dimension can be included multiple times in a Cube (role-playing dimensions feature), you won't be able to use the cube.Dimensions.Contain(...) method (because that method is based on the ID of the CubeDimension which is not necessarily the same as the ID of the Dimension). When checking if a CubeDimension points to your Dimension, it's faster to compare the string IDs (CubeDimension.DimensionID with Dimension.ID, case insensitive compare), than to use the CubeDimension.Dimension property (because that does a lookup).

The GetReferences method will do the same iterations over all the Cubes and their CubeDimensions, plus more (so it won't be faster than your code).

Adrian

|||Thx for your help Adrian!

AMO: list of cubes using a dim

Hello!

I'm trying to get a list of all cubes which are using a specific dimension with AMO. I could get a list of all cubes, then all dimensions used by each cube and check where my dimension is used but I feel there must be a more elegent solution ;-)
There is a GetReferences method in the Dimension object but I don't know how to use it, any idea or a better way to get my list ?

Other question: is there a way to automatically do a full or update process on each dim of a cube when we process this cube without having to list them all before ?

Thx!

I suggest to write the code that you mentioned: iterate over all Cubes and their CubeDimensions, checking which CubeDimension points to your Dimension. Because one Dimension can be included multiple times in a Cube (role-playing dimensions feature), you won't be able to use the cube.Dimensions.Contain(...) method (because that method is based on the ID of the CubeDimension which is not necessarily the same as the ID of the Dimension). When checking if a CubeDimension points to your Dimension, it's faster to compare the string IDs (CubeDimension.DimensionID with Dimension.ID, case insensitive compare), than to use the CubeDimension.Dimension property (because that does a lookup).

The GetReferences method will do the same iterations over all the Cubes and their CubeDimensions, plus more (so it won't be faster than your code).

Adrian

|||Thx for your help Adrian!

Friday, February 24, 2012

AMO: How to process after adding a measure?

Hi, friends, please look this:

dim tDatabase as Microsoft.AnalysisServices.DataBase

tDatabase=Mainform.AnalysisDB 'here to refer it to an object

tDatabase..Cubes(0).MeasureGroups(0).Measures.Add() 'here to add a measure

tDatabase..Cubes(0).Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull)

tDatabase.Process(Microsoft.AnalysisServices.ProcessType.ProcessUpdate)

I want to know if it's correct to use the ProcessType.ProcessUpdate option?

After adding/dropping a measure/KPI, what ProcessType need I use?

After update a dsv, what ProcessType need I use?

Thanks!

To the best of my knowledge processUpdate is only valid for dimensions (see http://msdn2.microsoft.com/en-us/library/ms345142.aspx)

If you add a measure you are changing the structure of the cube which will invalidate the cube, the easiest way to get the cube "fully operational" again would be to do a processFull. The same thing applies when removing a measure.

I don't think you need to do any processing for calculated measures or KPI's as these elements do not have storage structures associated with them.

As far as the DSV is concerned, it depends on the type of change you are making. Changing the DSV will not invalidate the cube structure as such. The DSV is an abstraction for the data source(s) of the cube. It depends on the type of changes you are making. If the data that comes out of the DSV is affected in any way, you would need to re-process the cube to get it to reflect these changes. More importantly, if you change data types or remove elements that other objects such as dimensions, partitions, measures etc. are dependant upon, then you would need to change those objects too and that would most likely require full re-processing.

|||

Thank you Gosbell ,

Please tell me if I drop or add a measure, if I always need to ProcessFull?

As you know, ProcessFull will take a very long time, specially when the cube is huge. I don't think the client could stand the long time just because he/she add or delete a measure thourgh my application with AMO.

How to deal with this problem?

|||

Please tell me if I drop or add a measure, if I always need to ProcessFull?

Yes, you do. You can add and remove calculations easy enough, but adding and removing measures that are linked to fact table columns changes the fundamental data structures. Adding and removing measures to a measureGroup is not really something to be done lightly, especially once a large cube has been deployed.

The bare minimum that you could do to get the cubes "queryable" again would be a processStructure followed by a processData, but the cubes would not have any indexes or aggregations, so they could be quite slow. Doing a processIndex would add the indexes and aggregations, but processFull is the effectively the same as doing all three of these operations individually. You might see a slight performance advantage by doing the three operations individually, but it would not be a dramatic change.

|||I see that. Thanks again, Gosbell!

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 Update

hi,friend, please have look:

I want to know, if I do:

dim tdatabase as Microsoft.AnalysisServices.database

' let tdatabase = someone existed on the server

tdatabase.update()

Will it cause the associated object be updated too ?

I mean, if I need NOT to do:

dsv.update()

dim.update()

cube.update()

measure.update()

and so on.

And, I can't find an update method on KPI. If that means I just need to update the cube object after I change a KPI object?

And, If I add/Remove a measure, need I do Process? Or just need to do Update?

Thanks!

ivanchain wrote:

I want to know, if I do:

dim tdatabase as Microsoft.AnalysisServices.database

' let tdatabase = someone existed on the server

tdatabase.update()

Will it cause the associated object be updated too ?

No it will not update all associated objects, see my next statment below.

ivanchain wrote:

I mean, if I need NOT to do:

dsv.update()

dim.update()

cube.update()

measure.update()

and so on.

The following is from this thread http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1842622&SiteID=1

Adrian Dumitrascu [MSFT]

The .Update() method only saves the minor properties and collections (thus not the major children) of an object. The major children are the AMO objects derived from the MajorObject class (Database, DataSource, Dimension, Cube, MeasureGroup, Partition, MiningStructure, MiningModel and others).

In our case, the database.Update() will save the database Name, ID, Description, Translations and other few minor properties, but won't save anything about the Role, which is a major object.

So you would need to call .Update on any major objects, so probably yes to dsv, dim, cube, but no to measure (I think a measure is a minor property of the measuregroup)

ivanchain wrote:

And, I can't find an update method on KPI. If that means I just need to update the cube object after I change a KPI object?

And, If I add/Remove a measure, need I do Process? Or just need to do Update?

If you add/remove a measure it will invalidate the cube structure, so once you do an update, your cube will be in an unprocessed state and you will need to process it.

|||

ivanchain wrote:

And, I can't find an update method on KPI. If that means I just need to update the cube object after I change a KPI object?

Yes, you need to call .Update() on the parent Cube. The Update method is only available on major objects (the ones that can be created, changed and deleted by themselves on the Analysis Services server - in AMO they are derived from the MajorObject class). To add/modify/delete a minor object (like Kpi, Measure, DimensionAttribute, Hierarchy, Level) you need to call .Update() on the parent major object.

|||

Very clear answer!

Thank you!

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!

Sunday, February 19, 2012

Ambiguous match found.

Does anyone know what this error means?

Ambiguous match found.

i'm using sql server 2000

here is my code

Dim con As SqlConnection = New SqlConnection

con.ConnectionString = _
"Data Source=localhost;" + _
"Initial Catalog=registeruser;" + _
"User ID=int422;" + _
"Password=int422"

Dim cmd As SqlCommand = New SqlCommand

cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT salt,hash FROM users WHERE login_id = '" + user.Text + "'"

Dim rdr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

con.Open()

Dim salt, hash As String

While rdr.Read()

If user.Text = rdr.Item("login_id").ToString() Then

salt = rdr.Item("salt").ToString()
hash = rdr.Item("hash").ToString()

End If

End While

con.Close()

Label1.Text = salt

End SubAre you sure that SQL statement is what is really getting called in your code ?

rdr.Item("login_id") wouldn't exist in the data reader as you have only selected "salt" and "hash".

<MindReading
My guess is, you haven't posted the SQL statement you are really using, you are using something with a JOIN in it and you are doing a SELECT * in there.
In your result set from the SQL statement, you have two columns called "login_id" so the dataReader doesn't know which one to reference.

If you change your SQL statement to only return the fields you want, you shouldn't have the problem

i.e. SELECT salt,hash, users.login_id FROM users INEER JOIN Blah etc etc

</MindReading