Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

christophebrault
Valued Contributor

Expression in Variable

Hi,

I'm using variable to store expression, but it's not working for a specific one :

LET vSommeCA = 'sum({$<DateFacture={">=$(=Min(Date))<=$(=Max(Date))"}>}FACT_LIGNE.CAHT)';

Any idea ?

Thanks

11 Replies

Re: Expression in Variable

Hi,

     Try SET instead of LET.

    

     SET vSommeCA = 'sum({$<DateFacture={">=$(=Min(Date))<=$(=Max(Date))"}>}FACT_LIGNE.CAHT)';

Regards,

Kaushik Solanki

christophebrault
Valued Contributor

Re: Expression in Variable

Still not working ...

Re: Expression in Variable

Probably it is due to  date format, try to transform everything in Num(date(...)).

this convert all dates to correspondand values and comparisons are surely correct

Obviously you have to add a field in the script that transform DateFacture to num(DateFacture)

Hopeit helps

Re: Expression in Variable

Hi,

     Kindly upload qvw file.

Regards,

Kaushik Solanki

Re: Expression in Variable

Another idea to test the expression is to substitute Min(Date) and Max(Date) with values you exect

for example:

SET vSommeCA = 'sum({$<DateFacture={">=19/04/2013<=21/04/2013"}>}FACT_LIGNE.CAHT)';

in this way you camìn understand better where is the problem

mov
Esteemed Contributor III

Re: Expression in Variable

When using dates in set analysis, I always make sure they are in date format, e.g.:

sum({$<DateFacture={">=$(=date(Min(Date)))<=$(=date(Max(Date)))"}>}FACT_LIGNE.CAHT)

christophebrault
Valued Contributor

Re: Expression in Variable

Have a look to the attached file please

Not applicable

Re: Expression in Variable

HI ,

     I dont know but have tried having "=" at the Begining like below

SET vSommeCA = "=sum({$<DateFacture={">=$(=Min(Date))<=$(=Max(Date))"}>}FACT_LIGNE.CAHT)";

//yusuf

kuba_michalik
Contributor III

Re: Expression in Variable

Trouble is, SET/LET will try to expand all $() expressions at assignment time. And I suppose you want to have $(=Min(Date)) in your expression, not whatever the min/max date is at the time of reload (actually, I highly suspect it would be (internal error) ;-) )

Probably easiest way to get around this would be to mask the $() expression somehow in SET, then unmask it using LET. Or go with LET and string concatenation, but that is, in my humble opinion, a pain.

Community Browser