Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Shoban_01
Partner - Contributor II
Partner - Contributor II

How to Get Current selection date range and show to prv and ytd

this is my code on  can you check this code is right or wrong?

Current 
=if(GetSelectedCount(Date)>1,
Sum({<Date={">=$(=Date(Min(Date)))<=$(=Date(Max(Date)))"}>Sales),
Sum({<Date= {">=$(=DATE(YEARSTART(TODAY())))<=$(=DATE(TODAY()))"}>}Sales))

Previous

if(GetSelectedCount(Date)>1,
Sum({<Date={">=$(=Date(min(AddYears(Date,-1))))<=$(=Date(max(AddYears(Date,-1))))"}>}Sales),
Sum({<Date= {">=$(=DATE(YEARSTART(YEARSTART(TODAY())-1)))<=$(=DATE(AddYears(TODAY(),-1)))"}>} Sales))

Labels (6)
1 Reply
sasikanth
Master
Master

HI, 

what do you want to achieve with above exp? Could you pls elaborate a bit more.

Can use below expressions for CYTD & PYTD.

CYTD;

Sum({<={>=$(=Date(YearStart(Max(Date)))) <= $(=Date(max(Date)))}>}Sales)

 

CYTD;

Sum({<={>=$(=Date(YearStart(Max(Date),-1))) <= $(=Date(addyears(max(Date),-1)))}>}Sales)

 

Thanks, 

Sasi