Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
hope this helps.
best
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
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,