2
votes

I'm trying to figure out how to get the data in a dimension via SSAS/MDX. Example:

DIMFileStatus
--------------
FileStatusID, FileStatusName
1             New
2             Updated
3             Deleted

If I run a simple query like:

SELECT [DimFileStatuses].[FileStatusName].members ON 0
FROM [status]

I get the following:

All  New  Updated  Deleted
--------------------------
1      1       1        1

What I want is:

FileStatusID  FileStatusName
          1    New
          2    Updated
          3    Deleted

How can I structure my query to get the results in the format I want? Thanks!


MORE INFO:

If I try to create a custom measure:

WITH MEMBER Measures.[custom] AS [DimFileStatuses].[FileStatusID].CURRENTMEMBER.MEMBERVALUE
SELECT [DimFileStatuses].[FileStatusName].members on 1,
[Measures].[custom] ON 0  
FROM [status]

I get:

        custom
--------------
all     (null)
New     (null)
Updated (null)
Deleted (null)
1
Always include a tag for the primary language the question pertains to (SQL in this case), otherwise your question won't have visibility to subject matter experts. Also, the language tag usually gives your code block snazzy syntax highlighting. - Adi Inbar
@AdiInbar Actually, here the language is MDX, not SQL - FrankPl
@FrankPl Sorry, my mistake. I fixed the tags. - Adi Inbar

1 Answers

3
votes

You can use

SELECT {}
       ON COLUMNS,
       [DimFileStatuses].[FileStatusID].[FileStatusID].Members
        *
       [DimFileStatuses].[FileStatusName].[FileStatusName].Members
       ON ROWS
  FROM [status]

Using the level that is named like the attribute name excludes the all member, and the Autoexists feature of Analysis Services should take care that all combinations of FileStatusID and FileStatusName returned by the cross join actually exist in the dimension table. This avoids pairs like (1, Updated).