Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below is my MDX query. Here I have applied sorting for one column, how can I sort all the columns, the reason behind this is, I no column should have any values like (null), null, empty, unknown etc.

SQL
WITH MEMBER PageSize AS
  1
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].[Budget Delivered COGS], [Measures].[Break Even Delivered] }
) ) 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]
)


In that query for the Break Even Delivered header it is showing (null) as the first value . How can we make the value which are not null to be on top? if that is for one column we can just apply a sorting. My requirement is, no column should have null values in the first cell if any of the cell contains values. Please suggest me any idea. Thanks in advance.
Posted

1 solution

I have done it by myself. I have changed the ROWAXISWOF as follows.

SQL
SET ROWAXISWOF AS
  NonEmpty (
  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] }  )


I have included NonEmpty conditions for each measures. Hope this will help some one.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900