Quantcast
Channel: SQL Server Analysis Services Forum
Viewing all articles
Browse latest Browse all 2472

Get first non-null values for all customers

$
0
0

Hi,

I am using SQL 2008R2, the Adventure Works database and I need to retrieve the first date with non-null Sales Amounts for each customer. The query is the following:

SELECT
{
     [Measures].[Sales Amount]
} ON 0,
NONEMPTY
(
     [Due Date].[Date Key].&[20010701]
    :[Due Date].[Date Key].[All].LastChild
    ,{
         [Measures].[Sales Amount]
    }
).ITEM(0)
ON 1
FROM [Adventure Works]
WHERE
(
    [Customer].[Full Name].&[11000]
)

While this correctly returns the first date in the specified interval with non-null sales amounts for customer 11000, I would need to achieve this for all customers and this is where I get stuck. So I need to incorporate the Customer dimension in the SELECT statement somehow and remove it from the WHERE clause.

Any help would be greatly appreciated!

Thank you!


Viewing all articles
Browse latest Browse all 2472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>