Showing posts with label measure. Show all posts
Showing posts with label measure. Show all posts

Saturday, February 25, 2012

AMO: Looping to delete partitions

Hi

I am trying - in AMO code - to loop over the partitions in my different measure groups and drop these. But apparently I am not allowed to do it with the following code, since I am modifying the collection which I am looping (because I drop the partitions which exist in the collection).

....

For Each oMeasuregroup in oCube.MeasureGroups

For Each oPartition in oMeasureGroup.Partitions

oPartition.Drop()

Next

Next

...

Can anyone help me with a solution? Thanks.

Hi,

You need to iterate over the partitions collection with integer index.

PartitionCollection partitions = ...;

for( int i=partitions.Count-1; i>=0; --i )
partitions[ i ].Drop();

Adrian Dumitrascu

Friday, February 24, 2012

AMO: How to ProcessFull a cube with no processing a Dimention?

Hi, friends, please have a look:

I just add a measure and do an Update to the cube object by AMO, and do a ProcessFull to the cube.

The problem is the ProcessFull will take a very long time. So I want to Process the cube with no processing the Dimentions, Could I do this?

Because I never change the Dimention, why the ProcessFull tot the cube will ALWAY process the dimentions by itself?

Thanks!

Hello! If you add a measure in a fact table you have actually change the whole structure of the cube and all aggregations will have to be rebuilt. That is why you will have to do a full process of the cube.

A full process of a dimension is only required if you change the structure like adding or changing user hierarchies and if you add or delete attributes. If this have not changed you can process(full) the cube and not the dimensions.

Processing dimensions normally takes less time than processing a cube(measure groups or partitions).

Adding calculated measures and other MDX -script objects do not require a full process. You can use process default in the user interface in BIDS to see that. I am not sure what that is called in AMO.

HTH

Thomas Ivarsson

|||

Thanks, Thomas.

Please just processfull the cube in the user interface in BIDS, NOT in AMO. You can see the process result report box, the ProcessFull to the cube will ALWAY make the dimentions be process ed automatically. Why and how to stop this?

|||

Hello! I think this can depend on a setting under "change setting" when you process the cube. Look for something like process affected objects.

HTH

Thomas Ivarsson

|||If you are doing this from BIDS, then adding a measure means you will need to re-deploy and if you have the default options set it will do a processDefault on the whole database. Which means that the cube that has been altered will be fully processed and the dimensions will all have processUpdate run on them to make sure that they have the latest information in them. If you want full control over the processing - do not use BIDS to process. Using XMLA commands from SSMS or ascmd is probably the best way to go. You could also write your own AMO utility in C# or VB.Net if you wanted.|||

Thanks Darren .

Then, you mean If I use AMO, and I use the cube(0).process(processFull), it WILL NOT make the dimention associated to be processed, right?

|||

A full process of a cube will always mean a full process of the dimensions.

HTH

Thomas Ivarsson

|||

ivanchain wrote:

Thanks Darren .

Then, you mean If I use AMO, and I use the cube(0).process(processFull), it WILL NOT make the dimention associated to be processed, right?

You can do cube(0).process(processDefault) to re-process the cube (and because you removed a measure, the Analysis Services server will decide to re-process the full measure group) without re-processing the dimensions. You can also call processDefault on the measure group, but it doesn't hurt to call it on the cube, the server will skip the other measure groups if they don't need to be re-processed.

The ProcessDefault option will only re-process what needs to be re-processed, if you did structural changes or not.

A description of the process types is available at: http://msdn2.microsoft.com/zh-cn/library/microsoft.analysisservices.processtype.aspx

|||

Adrian and Thomas are right, sorry I said processFull, but I was talking about processDefault.

Another good resource on processing is the Processing Architecture whitepaper: http://msdn2.microsoft.com/en-us/library/ms345142.aspx

|||

Thanks. From what you said, it means that I could always use ProcessDefault? Then why we need the ProcessFull?

Anyway, I will use ProcessDefault. OK?

|||

ProcessFull is to force a clean and full re-processing, if you want to do that.

|||

If I can say, I can always use ProcessDefault any time?

Thanks.

AMO: How to ProcessFull a cube with no processing a Dimention?

Hi, friends, please have a look:

I just add a measure and do an Update to the cube object by AMO, and do a ProcessFull to the cube.

The problem is the ProcessFull will take a very long time. So I want to Process the cube with no processing the Dimentions, Could I do this?

Because I never change the Dimention, why the ProcessFull tot the cube will ALWAY process the dimentions by itself?

Thanks!

Hello! If you add a measure in a fact table you have actually change the whole structure of the cube and all aggregations will have to be rebuilt. That is why you will have to do a full process of the cube.

A full process of a dimension is only required if you change the structure like adding or changing user hierarchies and if you add or delete attributes. If this have not changed you can process(full) the cube and not the dimensions.

Processing dimensions normally takes less time than processing a cube(measure groups or partitions).

Adding calculated measures and other MDX -script objects do not require a full process. You can use process default in the user interface in BIDS to see that. I am not sure what that is called in AMO.

HTH

Thomas Ivarsson

|||

Thanks, Thomas.

Please just processfull the cube in the user interface in BIDS, NOT in AMO. You can see the process result report box, the ProcessFull to the cube will ALWAY make the dimentions be process ed automatically. Why and how to stop this?

|||

Hello! I think this can depend on a setting under "change setting" when you process the cube. Look for something like process affected objects.

HTH

Thomas Ivarsson

|||If you are doing this from BIDS, then adding a measure means you will need to re-deploy and if you have the default options set it will do a processDefault on the whole database. Which means that the cube that has been altered will be fully processed and the dimensions will all have processUpdate run on them to make sure that they have the latest information in them. If you want full control over the processing - do not use BIDS to process. Using XMLA commands from SSMS or ascmd is probably the best way to go. You could also write your own AMO utility in C# or VB.Net if you wanted.|||

Thanks Darren .

Then, you mean If I use AMO, and I use the cube(0).process(processFull), it WILL NOT make the dimention associated to be processed, right?

|||

A full process of a cube will always mean a full process of the dimensions.

HTH

Thomas Ivarsson

|||

ivanchain wrote:

Thanks Darren .

Then, you mean If I use AMO, and I use the cube(0).process(processFull), it WILL NOT make the dimention associated to be processed, right?

You can do cube(0).process(processDefault) to re-process the cube (and because you removed a measure, the Analysis Services server will decide to re-process the full measure group) without re-processing the dimensions. You can also call processDefault on the measure group, but it doesn't hurt to call it on the cube, the server will skip the other measure groups if they don't need to be re-processed.

The ProcessDefault option will only re-process what needs to be re-processed, if you did structural changes or not.

A description of the process types is available at: http://msdn2.microsoft.com/zh-cn/library/microsoft.analysisservices.processtype.aspx

|||

Adrian and Thomas are right, sorry I said processFull, but I was talking about processDefault.

Another good resource on processing is the Processing Architecture whitepaper: http://msdn2.microsoft.com/en-us/library/ms345142.aspx

|||

Thanks. From what you said, it means that I could always use ProcessDefault? Then why we need the ProcessFull?

Anyway, I will use ProcessDefault. OK?

|||

ProcessFull is to force a clean and full re-processing, if you want to do that.

|||

If I can say, I can always use ProcessDefault any time?

Thanks.

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: Could I processfull on a measuregroup ONLY?

hi, friends,

I add/delete a measure in AMO. I want to know I need to processfull the whole cube or ONLY the measuregroup that associated?

Thanks!

I am quoting the Darren Gospbell's Reply to this quetion raised earlier in this forum:

"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.

Thanks

Subhash Subramanyam

|||

You mean that I need to process the WHOLE cube?

But I only process the measuregroup associated to the measure I just added, and no error reported.

I still think I need only to process the measuregroup associated.

What do you think?

Thanks.

|||

You only need to process the MeasureGroup. It is true that adding or removing a measure is a structural change that would clear the data (so re-processing is required), but the MeasureGroup is the most immediate parent containing the Partitions (who store the actual data) and Aggregations (who would need to be re-generated), so processing just the MeasureGroup should be enough.

But when saving the MeasureGroup (because you deleted the Measure), you might need to re-save the entire cube (with the ExpandFull option passed to the Update method) if you have Perspectives objects using that Measure.

Adrian Dumitrascu

|||

Thank you all!

AMO: Could I processfull on a measuregroup ONLY?

hi, friends,

I add/delete a measure in AMO. I want to know I need to processfull the whole cube or ONLY the measuregroup that associated?

Thanks!

I am quoting the Darren Gospbell's Reply to this quetion raised earlier in this forum:

"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.

Thanks

Subhash Subramanyam

|||

You mean that I need to process the WHOLE cube?

But I only process the measuregroup associated to the measure I just added, and no error reported.

I still think I need only to process the measuregroup associated.

What do you think?

Thanks.

|||

You only need to process the MeasureGroup. It is true that adding or removing a measure is a structural change that would clear the data (so re-processing is required), but the MeasureGroup is the most immediate parent containing the Partitions (who store the actual data) and Aggregations (who would need to be re-generated), so processing just the MeasureGroup should be enough.

But when saving the MeasureGroup (because you deleted the Measure), you might need to re-save the entire cube (with the ExpandFull option passed to the Update method) if you have Perspectives objects using that Measure.

Adrian Dumitrascu

|||

Thank you all!

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!

AMO created cube and Calculated Measures

I'm using AMO (based on the Adventure Works sample) to create a simple cube. I create it with a Measure Group named BaseFact that has 2 measures, Dollar Sales (DOLSLS) and Package Sales (PKGSLS). The cube create works and I can see the correct values for each of the measures when I browse it in Management Studio connected to Analysis Services.

To continue with the cube (and my education) I want to dynamically add a calculated measure or two. The forums seem to suggest that this is not possible using AMO and suggest using the cubes MdxScript to create calculated measures.

I used script to new query window to look at the XMLA script for the cube. There is no MdxScripts section in the XML text. If I look at the cube in the debugger it shows the MdxScripts collection count to be 0. After running the code below to get an MdxScript object, add new commands and update the cube I can again look at the XMLA for the cube and now there is a MdxScript with only the new measures I created. The measures also show up when I browse the cube. However, I can no longer see any data for the original measures or the added measures. I'd appreciate any help in understanding what is happening.

Server srv = new Server();
srv.Connect("localhost");
Database db = srv.Databases["MyCube"];
Cube cb = db.Cubes["MyCube"];
MdxScript ms = cb.MdxScripts.Add();
string cmd = "CREATE MEMBER CurrentCube.Measures.Price as [Measures].[DOLSLS] / [Measures].[PKGSLS]";
ms.Commands.Add(new Command(cmd));
cmd = "CREATE MEMBER CurrentCube.Measures.MyMem2 as [Measures].[Price] * 2";
ms.Commands.Add(new Command(cmd));
cmd = "CREATE MEMBER CurrentCube.Measures.MyMem3 as [Measures].[Price] * 3";
ms.Commands.Add(new Command(cmd));

ms.Update();
cb.Update();
cb.Process();
srv.Dispose();

Thanks
John

Solved it.
1. Added semi-colon to end of strings.
2. I thought I had read somewhere in the forums that the CALCULATE as the first command was optional but it isn't. Added the CALUCULATE and it all works.

John

AMO created cube and Calculated Measures

I'm using AMO (based on the Adventure Works sample) to create a simple cube. I create it with a Measure Group named BaseFact that has 2 measures, Dollar Sales (DOLSLS) and Package Sales (PKGSLS). The cube create works and I can see the correct values for each of the measures when I browse it in Management Studio connected to Analysis Services.

To continue with the cube (and my education) I want to dynamically add a calculated measure or two. The forums seem to suggest that this is not possible using AMO and suggest using the cubes MdxScript to create calculated measures.

I used script to new query window to look at the XMLA script for the cube. There is no MdxScripts section in the XML text. If I look at the cube in the debugger it shows the MdxScripts collection count to be 0. After running the code below to get an MdxScript object, add new commands and update the cube I can again look at the XMLA for the cube and now there is a MdxScript with only the new measures I created. The measures also show up when I browse the cube. However, I can no longer see any data for the original measures or the added measures. I'd appreciate any help in understanding what is happening.

Server srv = new Server();
srv.Connect("localhost");
Database db = srv.Databases["MyCube"];
Cube cb = db.Cubes["MyCube"];
MdxScript ms = cb.MdxScripts.Add();
string cmd = "CREATE MEMBER CurrentCube.Measures.Price as [Measures].[DOLSLS] / [Measures].[PKGSLS]";
ms.Commands.Add(new Command(cmd));
cmd = "CREATE MEMBER CurrentCube.Measures.MyMem2 as [Measures].[Price] * 2";
ms.Commands.Add(new Command(cmd));
cmd = "CREATE MEMBER CurrentCube.Measures.MyMem3 as [Measures].[Price] * 3";
ms.Commands.Add(new Command(cmd));

ms.Update();
cb.Update();
cb.Process();
srv.Dispose();

Thanks
John

Solved it.
1. Added semi-colon to end of strings.
2. I thought I had read somewhere in the forums that the CALCULATE as the first command was optional but it isn't. Added the CALUCULATE and it all works.

John

Sunday, February 19, 2012

AMO - measure numeric Value

I'm building a cube dynamically and i want to list just the columns in the fact table that are numeric in order to make Sum's, AVG's and so on.

How can i do this using AMO ?, i'm wondering if i can do this from the FactTable's (Data Table) DataColumns, but there is no metadata that tells me if the values there are or not valid numeric measures.

Regards Lisber.

Hi. I don't know the answer to your AMO question. However, I do know that you can get the metadata about your fact table from the system views in SQL Server 2005. For example, if you want to know the columns in a fact table with data type Money or Float the following query works against the sales fact in AdventureWorks schema:

SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'FactInternetSales'
AND (DATA_TYPE = 'float' OR DATA_TYPE = 'money')

A more extensive article about SQL Server 2005 metadata is available from Database Journal at this link:

http://www.databasejournal.com/features/mssql/article.php/3508881

Hope this helps - Paul Goldy

|||Thanks for your answer Paul,

The Problem that i have needs another solution because :( , i'm creating the cube dynamically:

I have the DataTable related to the fact table, but when i start creating the measures i need to do this:

(Copied from AdventureWorks - AMO Example)

meas.Source = CreateDataItem(db.DataSourceViews[0], "FactInternetSalesReason", "SalesOrderLineNumber");

but when i'm doing this dynamically i need to verify if "SalesOrderLineNumber" is or not a measure.

So in my case a have the factTable lets say "FactInternetSalesReason ", and i can make a loop through all of its dataTableColumns, here is where i need to know if that column is or not a valid measure in order to add it.

I'm following the AdventureWorks example, but as far as i can see all the cube creation is hard coded.|||HI. I understand the issue better now. Sorry, but I don't know how to determine if a column is a valid measure in your scenario. Paul Goldy|||Hey Lisber..

I'm not sure i fully understand, but what i gather is you want to add the measures from the fact table if it is some sort of numeric datatype in the table?

If that's the case, you've already got the datatable, so you can do something like this:

Dim DC as new DataColumn

For each DC in YOURDATASET.tables("YOURTABLENAME").Columns
If DC.DataType.Name = "Int32" '//Just an example
'//Add your measure here
End if
Next DC

If that's not what you mean, sorry :) If that is what you mean, and need more additional information, let me know..
C|||

Hi

Chris !, exactly i was thinking in the solution you described before , but i was having some troubles, here is the code that i use to figure out if a

data column is or not a measure ( ie, if its numeric ).

// 1o I make a loop through all the columns of my fact table ("FactResellerSales"), here is the code:

private void showMeasures()
{
for (int i = 0; i < this.dataSet.Tables["FactResellerSales"].Columns.Count; i++)
{
DataColumn column = this.dataSet.Tables["FactResellerSales"].Columns;
if (isMeasure(column.DataType))
Response.Write(column.ColumnName + "<br>");
}

}

private bool isMeasure(Type type)
{

switch (type.Name)
{
case "Int16": return (true);
case "Int32": return (true);
case "Int64": return (true);
case "Decimal": return (true);
case "Double": return (true);
case "Byte": return (true);
case "Boolean": return (true); // see better
default: return (false);

}
}

If anyone knows another way to figure out which columns in the fact table are measures or not, please tell me, because this solution is for sure not the best one !