Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

MDX Equivalent of HAVING COUNT()

$
0
0

I need to filter out a certain set of invocies from an MDX query. Sometimes an invoice has one entry, other times it may have two - an initial entry and then a subsequent void.

Accomplishing this within T-SQL is very straightforward:

select ar_inv_nbr
  from dim_ar_invoice
  group by ar_inv_nbr 
  having count(ar_inv_nbr) > 1
  order by ar_inv_nbr asc

I can then take the result set of invoice numbers and exclude them from any query.

I essentially need to perform the same type of query in MDX and use the results to filter an MDX statement. I don't want to display any invoices that have a count > 1. The current MDX statement:

SELECT 
  NON EMPTY 
    {
      [Measures].[AR INV PAID TO DATE]
     ,[Measures].[AR INV AMOUNT] 
     ,[Measures].[AR INV AGE]
     ,[Measures].[AR INV AMOUNT OUTSTANDING]
    } ON COLUMNS
 ,FILTER(NONEMPTY(
     {
         [DIM PROJECT].[Client].[Client].ALLMEMBERS*
         [DIM PROJECT].[Division].[Division].ALLMEMBERS*
         [DIM PROJECT].[Product].[Product].ALLMEMBERS*
         [DIM SALES CLASS].[Sales Class Type].[Sales Class Type].ALLMEMBERS*
         [DIM AR INVOICE].[Invoice Number].[Invoice Number].ALLMEMBERS*
         [DIM AR INVOICE].[Invoice Date].[Invoice Date].ALLMEMBERS*
         [DIM PROJECT].[Job Number].[Job Number].ALLMEMBERS*
         [DIM PROJECT].[Job].[Job].ALLMEMBERS
     },          [Measures].[AR INV AMOUNT]),
          [Measures].[AR INV AMOUNT] > .01)*
         [DIM INV AGE RANGE].[Invoice Age Range].[Invoice Age Range].ALLMEMBERS*
          [DIM INV AGE RANGE].[INV RANGE ID].[INV RANGE ID].ALLMEMBERS

  DIMENSION PROPERTIES 
    MEMBER_CAPTION
   ,MEMBER_UNIQUE_NAME
   ON ROWS

I'm guessing I would need to create some kind of named set and then include that set in the FILTER clause? Unfortunately, I'm not so hot with MDX!!

I've looked around and found several posts that are close to what I'm looking for, but not quite exactly.

The dimension that has the invocies is DIM_AR_INVOICE and the attribute is AR_INV_NBR.

Thanks for any help!


A. M. Robinson


Viewing all articles
Browse latest Browse all 14337

Trending Articles