[Mondrian] CASE/WHEN Statement in Where clause

Matt Campbell mcampbell at pentaho.com
Fri Jan 25 14:52:52 EST 2013


Kleyson's example didn't actually have a Boolean in the WHERE, it had a CASE statement that evaluates conditionally to a set.  That's supported, although a little odd.  The following query will run fine in Mondrian:

select  from sales WHERE
case when 'All' = 'All'  then gender.f else gender.m end



Kleyson, can you give a little background on the intent of your query?  There are probably more straightforward ways to construct it.





-----Original Message-----
From: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] On Behalf Of Julian Hyde
Sent: Friday, January 25, 2013 2:31 PM
To: Mondrian developer mailing list
Subject: Re: [Mondrian] CASE/WHEN Statement in Where clause



You've read the tutorial and you still think you can put a boolean expression in the WHERE clause? Read it again.



Julian





On Jan 25, 2013, at 10:30 AM, Kleyson Rios <kleyson.rios at saude.go.gov.br<mailto:kleyson.rios at saude.go.gov.br>> wrote:



> I Julian,

>

> Thanks for the answer.

>

> I've already read the tutorial.

>

> I am asking because in Microsoft website I saw an example using CASE/WHEN for select.

>

> I need to use the same idea for the WHERE.

>

> Can you give me a way in how to do that ?

>

> Thanks in advance.

>

> Kleyson Rios.

>

> ----- Mensagem original -----

> De: "Julian Hyde" <jhyde at pentaho.com<mailto:jhyde at pentaho.com>>

> Para: "Mondrian developer mailing list" <mondrian at pentaho.org<mailto:mondrian at pentaho.org>>

> Enviadas: Sexta-feira, 25 de Janeiro de 2013 16:14:45

> Assunto: Re: [Mondrian] CASE/WHEN Statement in Where clause

>

> You are making a mistake that many people make when learning MDX. You are assuming that the MDX WHERE clause has the same purpose as the SQL WHERE clause. MDX WHERE clause does not contain a boolean expression. I suggest that you read a tutorial on MDX.

>

> Julian

>

>

> On Jan 25, 2013, at 10:12 AM, Kleyson Rios <kleyson.rios at saude.go.gov.br<mailto:kleyson.rios at saude.go.gov.br>> wrote:

>

>>

>> Hi,

>>

>> Is it possible use CASE/WHEN in Where clause ?

>>

>> For example:

>>

>> select NON EMPTY {[Measures].[ConstStr]} ON COLUMNS, NON EMPTY

>> Order({[Convenio].[Todos convenios].Children},

>> [Measures].[Porcentagem], DESC) ON ROWS from [Fatur] where  CASE WHEN

>> 'All' = 'All' then {[Tempo].[2011]}

>>       ELSE Crossjoin({[Tempo].[2011]}, {[Tipo Despesa].[Honorario]})

>> END

>>

>> Thanks in advance.

>>

>> Kleyson Rios.

>> _______________________________________________

>> Mondrian mailing list

>> Mondrian at pentaho.org<mailto:Mondrian at pentaho.org>

>> http://lists.pentaho.org/mailman/listinfo/mondrian

>

> _______________________________________________

> Mondrian mailing list

> Mondrian at pentaho.org<mailto:Mondrian at pentaho.org>

> http://lists.pentaho.org/mailman/listinfo/mondrian

> _______________________________________________

> Mondrian mailing list

> Mondrian at pentaho.org<mailto:Mondrian at pentaho.org>

> http://lists.pentaho.org/mailman/listinfo/mondrian



_______________________________________________

Mondrian mailing list

Mondrian at pentaho.org<mailto:Mondrian at pentaho.org>

http://lists.pentaho.org/mailman/listinfo/mondrian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20130125/5b2baefe/attachment.html 


More information about the Mondrian mailing list