我正在使用SSAS MDX查询。现在我需要从MDX查询中识别每列的数据类型。我已经尝试过如下了。
WITH MEMBER PageSize AS 1 Member [Measures].[My Type] as TypeName([Measures].[Budget Delivered COGS])
但它会为货币字段返回两倍。首先,多维数据集的数据类型是货币,百分比?
如果没有,是否有办法找出该列是货币还是百分比,还是双倍或整数?
我看过这篇文章Find the data type。但这对货币和百分比来说是不可行的。
我在这里粘贴整个查询。
WITH MEMBER PageSize AS
1
MEMBER [Measures].[My Type] AS
TypeName ( [Measures].[Budget Delivered COGS] )
MEMBER [PageNumber] AS
1
MEMBER [Measures].[Orderby Measure] AS
[Measures].[Budget Delivered COGS]
MEMBER [Orderby] AS
"BASC"
SET ROWAXISWOF AS
NonEmpty (
( [Time Periods].[Fiscal Year].[Fiscal Year].Members, [Time Periods].[Fiscal Quarter].[Fiscal Quarter].Members, [Time Periods].[Fiscal Month].[Fiscal Month].Members, [Time Periods].[Fiscal Week].[Fiscal Week].Members ),
{
{ [Measures].[Budget Delivered COGS] },
{ [Measures].[Break Even Delivered] }
}
)
SET ROWAXISWF AS
Filter ( ROWAXISWOF, [Measures].[Budget Delivered COGS] )
SET ROWAXIS AS
IIf ( 'Filter' = "NotFilter", ROWAXISWF, ROWAXISWOF )
MEMBER [Measures].[MaxRowCount] AS
ROWAXIS .Count
SET ROWAXIS_Count AS
IIf (
'Paging' = "Paging",
(
CASE
WHEN [Orderby] = 'BASC'
THEN Tail (
TopCount ( ROWAXIS, PageSize * PageNumber, [Measures].[Orderby Measure] ),
PageSize
)
ELSE Tail (
BottomCount ( ROWAXIS, PageSize * PageNumber, [Measures].[Orderby Measure] ),
PageSize
) END ),
ROWAXISWOF
)
SELECT ( IIf (
'Paging' = "Paging",
(
{ [Measures].[Budget Delivered COGS], [Measures].[Break Even Delivered], [Measures].[MaxRowCount], [Measures].[My Type] } ),
{ [Measures].[Budget Delivered COGS], [Measures].[Break Even Delivered], [Measures].[My Type] }
) ) ON COLUMNS,
ROWAXIS_Count ON ROWS
FROM (
SELECT (
{ [Time Periods].[Fiscal Year].&[2011], [Time Periods].[Fiscal Year].&[2012], [Time Periods].[Fiscal Year].&[2013], [Time Periods].[Fiscal Year].&[2014], [Time Periods].[Fiscal Year].&[2015] } ) ON COLUMNS
FROM [Homestore Sales]
)
如果我们在查询中获取数据,我将遍历该列并在C#中找到。任何帮助深表感谢。提前谢谢。
答案 0 :(得分:2)
如果您正在讨论物理测量,那么您可以在SSAS项目中查看SSDT-BI以查看测量类型。或者您可以使用以下SSAS sproc批量导出它,您可以安装here:
CALL ASSP.discoverXmlMetaData("\Database\Cubes\Cube\MeasureGroups\MeasureGroup|Name\Measures\Measure");
计算的措施比较棘手。由于计算中的IIF语句和范围语句,CalculatedMeasure1可能在一个单元格中为Double,在另一个单元格中为String。您可以运行查询并返回一个CellSet,然后查看每个单元格的类型,我认为它应该告诉您类型。但是,我不确定在给定类型的情况下,即使在相同的计算度量中,类型也会有所不同。
也许您想要检索计算度量的FORMAT_STRING属性?这可能表明会发生什么。在生成的CellSet中,您将能够从每个单元格中检索FORMAT_STRING属性。
select {[Measures].[Budget Delivered COGS], [Measures].[Break Even Delivered]} on 0
FROM [Homestore Sales]
PROPERTIES VALUE, FORMAT_STRING
如果要假设每个度量对于多维数据集中的所有单元格具有相同的格式字符串,最后一种方法是查询MDSCHEMA_MEASURES DMV。它有一个DEFAULT_FORMAT_STRING列。您可以使用针对SSAS的SQL查询来调用它,例如:
select * from $system.mdschema_measures
或者您可以通过ADOMD.NET使用以下代码调用它:
AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection();
restrictions.Add(new AdomdRestriction("CATALOG_NAME", cube.ParentConnection.Database));
restrictions.Add(new AdomdRestriction("CUBE_NAME", cube.Name));
System.Data.DataTable tblExactMatchMembers = conn.GetSchemaDataSet("MDSCHEMA_MEASURES", restrictions).Tables[0];
如果这不能回答你的问题,你可以提供一些你想要完成的背景。