Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I have a calculation giving me a date range ' > =' & date (min (Date) ) & '< =' & date ( AddYears ( max ( date) , - 1 ) )
But when I define this calculation as a variable that does not work in the set analysis
= sum ( { <Date = { $ (variable) } >} [Ca CDE ] )
Can you help me?
Thank you
why not use
sum ( { <Date = {"> =$(= date (min (Date) ) ) < =$(=date ( AddYears ( max ( date) , - 1 ) ))"} >} [Ca CDE ] )
why not use
sum ( { <Date = {"> =$(= date (min (Date) ) ) < =$(=date ( AddYears ( max ( date) , - 1 ) ))"} >} [Ca CDE ] )
this is my expression
sum({$ <d={"$(variable)"} >} [Ca CDE ] )
and this variable (with equal sign), the date field is d I used to test it
= '>=' & date(min(d)) & '<=' & date ( AddYears ( max (d), -0 ) )
and it works
you have the field date and Date (Qlik is case sensitive!!!)
EDIT
attached an example
hi,
Try
=Sum({<Date = {">=$(=Date(Min(Date))) <=$(=Date(Max(Date)-1))"}>}[Ca CDE ])
Use it in double quotes
sum ( { <Date = { "$ (variable) "} >} [Ca CDE ] )
hth
sasi
Dear Saoud,
Please first check your variable value either it's coming in number format or date format. If it is coming in number format then please use Data function and convert into proper format.
However, please use single quotation and double quotation in against of Dollar sign expansion to check which one is working.
Kind regards,
Ishfaque Ahmed
Hi,
Instead of storing expression in single variable, create two variables with start and End dates like below and use those in Set analysis expression, this will make the expression meaningful to read and easily to understand and debug if there is any issue.
vStartDate = date (min (Date) )
vEndDate = date ( AddYears ( max ( date) , - 1 ) )
Variables in expressions:
= sum ( { <Date = { '>=$(=vStartDate)<=$(=vEndDate ) ' } >} [Ca CDE ] )
Hope this helps you.
Regards,
Jagan.
Hi,
Thanks a lot it works
perfect thanks
Dear Ahmed,
Thank you for tour response it"s a good solution
best regards