Wednesday, March 7, 2012

MDX Query to display no records for empty rows

Hi,

I am facing with the following problem.

I am using bar chart to display my report.

My MDX query is as follows:

SELECT
NON EMPTY { [Measures].[SUM_COUNT] } ON COLUMNS,
TopCount ( Filter ( {[DIM].[NAME].[NAME]}, [Measures].[SUM_COUNT] <> 0 ) , 10, [Measures].[SUM_COUNT] ) ON ROWS
FROM
[USAGE]

where <criteria>

I want to show the topmost 10 records. For some criteria I get the results in the chart.

But for some criteria or say for wrong criteria, there are no records. In such a case the X-axis contains all values for {[DIM].[NAME].[NAME] and value for the Y-axis is all 0. Its kind of blank report it will restrict to 10 records.

In such a scenario I want to show a message to the user saying "No records found", which I have set in the No Rows property of the chart.

If I remove the TopCount clause then I get the above message, which is obvious.

So how do I acheive the same message but at the same time limiting the records to 10?

How can I acheive this in my scenario? Can something be done at the query end?

any help is appreciated.

Thanks in advance!

I could solve my problem by the following query

SELECT
NON EMPTY { [Measures].[SUM_COUNT] } ON COLUMNS,
NON EMPTY TopCount ( Filter ( {[DIM].[NAME].[NAME]}, [Measures].[SUM_COUNT] <> 0 ) , 10, [Measures].[SUM_COUNT] ) ON ROWS
FROM
[USAGE]

|||I have a similur problem. What I need to do is display a message to the user "No Records Found" if there query returns no hits? I knwo a way to do this with SQL, but i'm not sure how I can do this with in the SQL reporting services.

Thanks,|||What I ended up doing was adding a footer to the report and putting the following logic in that footer: =IIF(IsNothing(Fields!yourFieldHere), "No Records Found", "").

Hope it helps.

No comments:

Post a Comment