Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
christophebrault
Specialist
Specialist

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

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
11 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try SET instead of LET.

    

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

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
christophebrault
Specialist
Specialist
Author

Still not working ...

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
alexandros17
Partner - Champion III
Partner - Champion III

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

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Kindly upload qvw file.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
alexandros17
Partner - Champion III
Partner - Champion III

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

Anonymous
Not applicable

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
Specialist
Specialist
Author

Have a look to the attached file please

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
Not applicable

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
Partner - Specialist
Partner - Specialist

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.