Showing posts with label believe. Show all posts
Showing posts with label believe. Show all posts

Tuesday, March 27, 2012

Alias or Group SSAS Dimension at Query time.

In an MDX Query i am trying to alias (or group ) the returned dimension as shown below but i am getting the wrong result.I believe the issue is in the case statement logic.

Is there a way to alias (or group dynamically) dimension without creating a named column in DSV?

Any help will be appreciated.

WITH MEMBER [Measures].[Long] AS

IIF(

[Measures].[Risk Value]<0,

[Measures].[Risk Value],

null)

SET [GroupedRatings] AS

CASE

WHEN [Curve Family].[SP Rating].&[AA-] THEN [Curve Family].[SP Rating].&[AA]

WHEN [Curve Family].[SP Rating].&[AA+] THEN [Curve Family].[SP Rating].&[AA]

WHEN [Curve Family].[SP Rating].&[AAA+] THEN [Curve Family].[SP Rating].&[AAA]

WHEN [Curve Family].[SP Rating].&[AAA+] THEN [Curve Family].[SP Rating].&[AAA]

WHEN [Curve Family].[SP Rating].&[BB-] THEN [Curve Family].[SP Rating].&[BB]

WHEN [Curve Family].[SP Rating].&[BB+] THEN [Curve Family].[SP Rating].&[BB]

WHEN [Curve Family].[SP Rating].&[BBB+] THEN [Curve Family].[SP Rating].&[BBB]

ELSE NULL

END

SELECT { [Measures].[Long]} ON COLUMNS,

{ ([GroupedRatings]*[Book].[Desk].[Desk].Members) } --cross join grouped rating and desk members

ON ROWS

FROM [DM]

This is where the similarities between MDX and SQL can be confusing. What you really want to do is to create some calculated members to do your grouping and then create a set of these members.

eg.

WITH MEMBER [Measures].[Long] AS

IIF(

[Measures].[Risk Value]<0,

[Measures].[Risk Value],

null)

MEMBER [Curve Family].[SP Rating].&[AA] AS Aggregate({[Curve Family].[SP Rating].&[AA-],[Curve Family].[SP Rating].&[AA+]})

MEMBER [Curve Family].[SP Rating].&[AAA] AS Aggregate({[Curve Family].[SP Rating].&[AAA-],[Curve Family].[SP Rating].&[AAA+]}

MEMBER [Curve Family].[SP Rating].&[BB] AS Aggregate({[Curve Family].[SP Rating].&[BB-], [Curve Family].[SP Rating].&[BB+]})

MEMBER [Curve Family].[SP Rating].&[BBB] AS Aggregate({[Curve Family].[SP Rating].&[BBB+]})

SET [GroupedRatings] AS

{[Curve Family].[SP Rating].&[AA]
,[Curve Family].[SP Rating].&[AAA]
,[Curve Family].[SP Rating].&[BB]
,[Curve Family].[SP Rating].&[BBB]}

SELECT { [Measures].[Long]} ON COLUMNS,

{ ([GroupedRatings]*[Book].[Desk].[Desk].Members) } --cross join grouped rating and desk members

ON ROWS

FROM [DM]

|||

The case statement won't create new members dynamically, which it looks like you're trying to do. You could declare each member explicitly, like:

WITH MEMBER [Measures].[Long] AS

IIF(

[Measures].[Risk Value]<0,

[Measures].[Risk Value],

null)

Member [Curve Family].[SP Rating].[AA] as

Sum({[Curve Family].[SP Rating].&[AA-], [Curve Family].[SP Rating].&[AA+]}),

SOLVE_ORDER = 10

Member [Curve Family].[SP Rating].[AAA] as

Sum({[Curve Family].[SP Rating].&[AAA-], [Curve Family].[SP Rating].&[AAA+]}),

SOLVE_ORDER = 10

Member [Curve Family].[SP Rating].[BB] as

Sum({[Curve Family].[SP Rating].&[BB-], [Curve Family].[SP Rating].&[BB+]}),

SOLVE_ORDER = 10

Member [Curve Family].[SP Rating].[BBB] as

Sum({[Curve Family].[SP Rating].&[BBB-], [Curve Family].[SP Rating].&[BBB+]}),

SOLVE_ORDER = 10

SET [GroupedRatings] AS

{[Curve Family].[SP Rating].[AA], [Curve Family].[SP Rating].[AAA],

[Curve Family].[SP Rating].[BB], [Curve Family].[SP Rating].[BBB]}

SELECT { [Measures].[Long]} ON COLUMNS,

{ ([GroupedRatings]*[Book].[Desk].[Desk].Members) } --cross join grouped rating and desk members

ON ROWS

FROM [DM]

|||

Thanks Darren for pointing me in the right direction.I changed the code to the sample below to make it work properly.

WITH

MEMBER [Curve Family].[SP Rating].[AA] AS

Aggregate({FILTER([Curve Family].[SP Rating].&[AA-],([Measures].[Risk Value])<0),FILTER([Curve Family].[SP Rating].&[AA+],([Measures].[Risk Value])<0)})

MEMBER [Curve Family].[SP Rating].[AAA] AS

Aggregate({FILTER([Curve Family].[SP Rating].&[AAA-],([Measures].[Risk Value])<0),FILTER([Curve Family].[SP Rating].&[AAA+],([Measures].[Risk Value])<0)})

MEMBER [Curve Family].[SP Rating].[BB] AS

Aggregate({FILTER([Curve Family].[SP Rating].&[BB-],([Measures].[Risk Value])<0),FILTER([Curve Family].[SP Rating].&[BB+],([Measures].[Risk Value])<0)})

MEMBER [Curve Family].[SP Rating].[BBB]AS

Aggregate({FILTER([Curve Family].[SP Rating].&[BBB-],([Measures].[Risk Value])<0),FILTER([Curve Family].[SP Rating].&[BBB+],([Measures].[Risk Value])<0)})

SET [GroupedRatings] AS

{

[Curve Family].[SP Rating].[AA]

,[Curve Family].[SP Rating].[AAA]

,[Curve Family].[SP Rating].[BB]

,[Curve Family].[SP Rating].[BBB]

}

SELECT

NON EMPTY { [Measures].[Risk Value]} ON COLUMNS,

NON EMPTY {([GroupedRatings]*[Vdim Book].[Desk].[Desk].Members)} ON ROWS

FROM

[DM]

Friday, February 24, 2012

Agent & Replication - missing and missed!

I can't believe this. MSDE was a great product and I'm sure that SQL Express is even better. The difference is that I can't migrate any of my company's applications to it because they rely on a Replication architecture (requiring Replication Publication). And SQL Agent, how are you supposed to keep the database in good shape if you can't run Maintenance Plans at scheduled intervals?

I know, there are third party products out there to compensate for the lack of the SQL Agent, but they don't solve the replication problem. Besides, the Agent still exists in other editions - it's not like it has been dropped completely. Why do we have to lose functionality and features? We have already lost the use of a second CPU and memory > 1GB. Why do they need to keep taking stuff out? Why don't they just limit access to the new feature-set?

I would rather lose the new features such as Report Server and Full Text Indexing and get the SQL Agent and Replication Publication back. I can almost understand that with a free product, they don't want to keep piliing new features in just to give them away - even though I'm sure the sale of the larger editions more than covers the R&D investment in their construction. Why can't we chose? Agent or Report Server, Replication or Full Text Indexing? I don't need some of these new features (others might), I just want the features that I used to have. Perhaps SQL 2005 setup can be made to choose 2 out of the 4 features?

Whats more, I can't even say that I'll just stick with MSDE, as it now has a limited support life. Microsoft announced that any SQL Server version prior to 2005 SP1 will NOT be supported on Vista or Longhorn Server (nor does it support anything less than Windows 2000 SP4 or Windows XP SP2 where MSDE does).

OK - let me get this right. We had something that has been taken away in the new version. Perhaps I don't deserve the new version if I don't pay for it - fine - I'll stick to the old one I already have. BUT wait... I can't use that on the new platforms coming out.

Are my entry-level customers going to pay for the Workgroup Edition (add AUD$1200 to my entry level edition application of AUD$1500) to replace the Replication Publisher and provide a Maintenance plan? Is anyone going to pay for the re-architecting and re-construction of my application to work around these new limitations?

I guess that will be me. Is this what happens for being loyal to MS products?

Please - give back the SQL Agent and Replication publication.

Joe

Joe, I completley agree with you, and its really sad that no one from microsoft has bothered to answer your comments.

Agent & Replication - missing and missed!

I can't believe this. MSDE was a great product and I'm sure that SQL Express is even better. The difference is that I can't migrate any of my company's applications to it because they rely on a Replication architecture (requiring Replication Publication). And SQL Agent, how are you supposed to keep the database in good shape if you can't run Maintenance Plans at scheduled intervals?

I know, there are third party products out there to compensate for the lack of the SQL Agent, but they don't solve the replication problem. Besides, the Agent still exists in other editions - it's not like it has been dropped completely. Why do we have to lose functionality and features? We have already lost the use of a second CPU and memory > 1GB. Why do they need to keep taking stuff out? Why don't they just limit access to the new feature-set?

I would rather lose the new features such as Report Server and Full Text Indexing and get the SQL Agent and Replication Publication back. I can almost understand that with a free product, they don't want to keep piliing new features in just to give them away - even though I'm sure the sale of the larger editions more than covers the R&D investment in their construction. Why can't we chose? Agent or Report Server, Replication or Full Text Indexing? I don't need some of these new features (others might), I just want the features that I used to have. Perhaps SQL 2005 setup can be made to choose 2 out of the 4 features?

Whats more, I can't even say that I'll just stick with MSDE, as it now has a limited support life. Microsoft announced that any SQL Server version prior to 2005 SP1 will NOT be supported on Vista or Longhorn Server (nor does it support anything less than Windows 2000 SP4 or Windows XP SP2 where MSDE does).

OK - let me get this right. We had something that has been taken away in the new version. Perhaps I don't deserve the new version if I don't pay for it - fine - I'll stick to the old one I already have. BUT wait... I can't use that on the new platforms coming out.

Are my entry-level customers going to pay for the Workgroup Edition (add AUD$1200 to my entry level edition application of AUD$1500) to replace the Replication Publisher and provide a Maintenance plan? Is anyone going to pay for the re-architecting and re-construction of my application to work around these new limitations?

I guess that will be me. Is this what happens for being loyal to MS products?

Please - give back the SQL Agent and Replication publication.

Joe

Joe, I completley agree with you, and its really sad that no one from microsoft has bothered to answer your comments.

Again a date problem inside MSSQL server

I am having java code which inserts date (which is in String format) into
MSSQL table.
The format of date is "yyyy-MM-dd hh:mm:ss" (I believe this is a standard
format ?). On my local m/c it was working fine, but when shifted to new
serverit stopped working. On new serverit takes "dd/MM/yyyy hh:mm:ss" format
only. the above format - it gives me Airthmatic overflow error.
1)Is there any standard format which will always work on MSSQL ?
2)btw, how this format is set on SQL server ? Can i change the date format
to be displayed on Enterprise manager ?
regards
Manisha
check out the ISO8601 format; search BOL for convert using style 126. This
format is international and will always work no matter how the SQL Server is
set up.
yyyy-mm-ddThh:mm:ss:mmm(no spaces)
regards,
Mark Baekdal
http://www.dbghost.com
+44 (0)208 241 1762
Database change management for SQL Server
"manisha_css" wrote:

> I am having java code which inserts date (which is in String format) into
> MSSQL table.
> The format of date is "yyyy-MM-dd hh:mm:ss" (I believe this is a standard
> format ?). On my local m/c it was working fine, but when shifted to new
> serverit stopped working. On new serverit takes "dd/MM/yyyy hh:mm:ss" format
> only. the above format - it gives me Airthmatic overflow error.
> 1)Is there any standard format which will always work on MSSQL ?
> 2)btw, how this format is set on SQL server ? Can i change the date format
> to be displayed on Enterprise manager ?
> regards
> Manisha
>
>
|||BOL - writing international transact-sql statements
"manisha_css" <manishacss@.discussions.microsoft.com> wrote in message
news:6017A109-369E-48B5-B6B0-3F6DDCF773F3@.microsoft.com...
> I am having java code which inserts date (which is in String format) into
> MSSQL table.
> The format of date is "yyyy-MM-dd hh:mm:ss" (I believe this is a standard
> format ?). On my local m/c it was working fine, but when shifted to new
> serverit stopped working. On new serverit takes "dd/MM/yyyy hh:mm:ss"
format
> only. the above format - it gives me Airthmatic overflow error.
> 1)Is there any standard format which will always work on MSSQL ?
> 2)btw, how this format is set on SQL server ? Can i change the date format
> to be displayed on Enterprise manager ?
> regards
> Manisha
>
>

Again a date problem inside MSSQL server

I am having java code which inserts date (which is in String format) into
MSSQL table.
The format of date is "yyyy-MM-dd hh:mm:ss" (I believe this is a standard
format '). On my local m/c it was working fine, but when shifted to new
serverit stopped working. On new serverit takes "dd/MM/yyyy hh:mm:ss" format
only. the above format - it gives me Airthmatic overflow error.
1)Is there any standard format which will always work on MSSQL ?
2)btw, how this format is set on SQL server ? Can i change the date format
to be displayed on Enterprise manager ?
regards
Manishacheck out the ISO8601 format; search BOL for convert using style 126. This
format is international and will always work no matter how the SQL Server is
set up.
yyyy-mm-ddThh:mm:ss:mmm(no spaces)
regards,
Mark Baekdal
http://www.dbghost.com
+44 (0)208 241 1762
Database change management for SQL Server
"manisha_css" wrote:
> I am having java code which inserts date (which is in String format) into
> MSSQL table.
> The format of date is "yyyy-MM-dd hh:mm:ss" (I believe this is a standard
> format '). On my local m/c it was working fine, but when shifted to new
> serverit stopped working. On new serverit takes "dd/MM/yyyy hh:mm:ss" format
> only. the above format - it gives me Airthmatic overflow error.
> 1)Is there any standard format which will always work on MSSQL ?
> 2)btw, how this format is set on SQL server ? Can i change the date format
> to be displayed on Enterprise manager ?
> regards
> Manisha
>
>|||BOL - writing international transact-sql statements
"manisha_css" <manishacss@.discussions.microsoft.com> wrote in message
news:6017A109-369E-48B5-B6B0-3F6DDCF773F3@.microsoft.com...
> I am having java code which inserts date (which is in String format) into
> MSSQL table.
> The format of date is "yyyy-MM-dd hh:mm:ss" (I believe this is a standard
> format '). On my local m/c it was working fine, but when shifted to new
> serverit stopped working. On new serverit takes "dd/MM/yyyy hh:mm:ss"
format
> only. the above format - it gives me Airthmatic overflow error.
> 1)Is there any standard format which will always work on MSSQL ?
> 2)btw, how this format is set on SQL server ? Can i change the date format
> to be displayed on Enterprise manager ?
> regards
> Manisha
>
>

Again a date problem inside MSSQL server

I am having Java code which inserts date (which is in String format) into
MSSQL table.
The format of date is "yyyy-MM-dd hh:mm:ss" (I believe this is a standard
format '). On my local m/c it was working fine, but when shifted to new
serverit stopped working. On new serverit takes "dd/MM/yyyy hh:mm:ss" format
only. the above format - it gives me Airthmatic overflow error.
1)Is there any standard format which will always work on MSSQL ?
2)btw, how this format is set on SQL server ? Can i change the date format
to be displayed on Enterprise manager ?
regards
Manishacheck out the ISO8601 format; search BOL for convert using style 126. This
format is international and will always work no matter how the SQL Server is
set up.
yyyy-mm-ddThh:mm:ss:mmm(no spaces)
regards,
Mark Baekdal
http://www.dbghost.com
+44 (0)208 241 1762
Database change management for SQL Server
"manisha_css" wrote:

> I am having Java code which inserts date (which is in String format) into
> MSSQL table.
> The format of date is "yyyy-MM-dd hh:mm:ss" (I believe this is a standard
> format '). On my local m/c it was working fine, but when shifted to new
> serverit stopped working. On new serverit takes "dd/MM/yyyy hh:mm:ss" form
at
> only. the above format - it gives me Airthmatic overflow error.
> 1)Is there any standard format which will always work on MSSQL ?
> 2)btw, how this format is set on SQL server ? Can i change the date format
> to be displayed on Enterprise manager ?
> regards
> Manisha
>
>|||BOL - writing international transact-sql statements
"manisha_css" <manishacss@.discussions.microsoft.com> wrote in message
news:6017A109-369E-48B5-B6B0-3F6DDCF773F3@.microsoft.com...
> I am having Java code which inserts date (which is in String format) into
> MSSQL table.
> The format of date is "yyyy-MM-dd hh:mm:ss" (I believe this is a standard
> format '). On my local m/c it was working fine, but when shifted to new
> serverit stopped working. On new serverit takes "dd/MM/yyyy hh:mm:ss"
format
> only. the above format - it gives me Airthmatic overflow error.
> 1)Is there any standard format which will always work on MSSQL ?
> 2)btw, how this format is set on SQL server ? Can i change the date format
> to be displayed on Enterprise manager ?
> regards
> Manisha
>
>