Search code examples
sqlsql-serverssasmdxanalysis

Analysis Services - calculated member - count by dimension key range


Hello I´m struggling with MS SSAS... simplified I have two tables in my Data-view. T1 holds a PK and a Date. T2 holds a PK, a FK of T1, and some numbers.

I created an dimension from T1 with its two attributes. So I can created a Cube to aggregate the Data of T2 by date and id of T1. So far so good.

What I want to do next is the aggregation of just a part of that data. Example: "Show me the aggregated data of T2 records that have a FK >=970"

So I tried to write a calculated measure, but failed. I searched around the web but I found nothing worked so far...

I hope someone can help with a hint.


Solution

  • If i understood correctly, your date Dimension is T1.

    In your dimension you should have a dimension Key setup, i'll assume you did it at the PK column. Within the properties you can define 3 things for that attribute. KeyColumns NameColumns ValueColumns

    Make sure your KeyColumns is the PK Column. And should be a OrderBy property you should make sure is set to "Key"

    After that if your PKs are sequencial(they really should!) you can make a MDX query like this:

    SELECT
    { [Measures].[YOURMEASURE] } ON COLUMNS,
    { [T1].&[970] : NULL } ON ROWS
    FROM [MyCube]
    

    EDIT: Sure. Add to your Calculation in the Cube.

    CREATE MEMBER CURRENTCUBE.[Measures].[MyOver970Measure]
    AS
    AGGREGATE({ [T1].&[970] : NULL },[Measures].[YOURMEASURE])
    ,VISIBLE=1;