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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
gowrishankarangrybird
Contributor II
Contributor II

How to show particular Date Range in x axis: I need to show only 01-01-2017 to 30-10-2017

Hi Guys,

I need to show only 01-01-2017 to 30-10-2017 and 

01-01-2022 to today 

How to write expression for this Min and max Date range. 

Thanks in advance 

gowrishankarangrybird_0-1666174277002.png

 

3 Replies
RafaelBarrios
Partner - Specialist
Partner - Specialist

Hi @gowrishankarangrybird 

01-01-2022 to today
Sum({<date_field={
">=$(=YearStart(today()))<=$(=today())"} >} sales)

01-01-2022 to end of October
Sum({<date_field={
">=$(=YearStart(today()))<=$(=monthend(today()))"} >} sales)


and for changing years, you could use addyears(today(),-5) to today in 2017 and so on 

https://help.qlik.com/es-ES/qlikview/May2022/Subsystems/Client/Content/QV_QlikView/Scripting/DateAnd...

 

hope this helps.

best

gowrishankarangrybird
Contributor II
Contributor II
Author

Hi Rafael, thanks for your response.  

 

Is there any possible to write expression without sum (). 

incase i need to 17-06-2017 to 19-03-2018 means How 

RafaelBarrios
Partner - Specialist
Partner - Specialist

hi @gowrishankarangrybird 

im not sure why you would need that.
for a measure in a chart, you will always need a aggregation SUM, COUNT, MIN, MAX, AVG, ONLY.....

 

what is usually done is to use variables and set to work according to your selections, today's date or the Max/Min value when nothing is selected, in this way you can reuse in other formulas

vMinDate
=if(getSelectedCount(date_field)=0,yearstart(today()),date(min(date_field)))

vMaxDate
=if(getSelectedCount(date_field)=0,today(),date(max(date_field)))

make sure to use the '=' symbol when defining the variable

 

and then used in any formula

Sum({<date_field={">=$(vMinDate)<=$(vMaxDate)"} >} sales)
AVG({<date_field={">=$(vMinDate)<=$(vMaxDate)"} >} sales)
count({<date_field={">=$(vMinDate)<=$(vMaxDate)"} >} clients)

or could also use to display in text objects

='showing data from ' & vMinDate & ' to ' & vMaxDate

 

Best,

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution.