Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
I want a measure to compare one time range sales with previous year same time range sales. For example:
If selected time range A (for a given alt_state)--> 2020-09-01 to 2020-09-30, I need a measure like this:
sum({alt_state} sales)-sum({alt_state <date={'$(=AddYears(date,-1))'}>} sales)
(this doesn't work)
So I can get this:
| date | AddYears(date,-1) | sales | previous sales | diff |
| 2020-09-01 | 2019-09-01 | 100 | 95 | 5 |
| 2020-09-02 | 2019-09-02 | 120 | 130 | -10 |
| ... | ... | ... | ... | ... |
or even this:
| month(date) | month(AddYears(date,-1)) | sales | previous sales | diff |
| sept-2020 | sept-2019 | 3000 | 2500 | 500 |
| oct-2020 | oct-2019 | 3250 | 3300 | -50 |
| .. | ... | ... | ... | ... |
or a bar chart where Dimension = month(date) and Measure is the diff for alt_state month vs previous year, with only the days selected (if from 2nd to 15th of sept selected, month(date) would be sept-2020 but just with information from 2nd to 15th sept)
Thanks!
I would define a field in the script for this, e.g.
Date - YearStart(Date) as DayWithinYear,
You can even format it as month+day:
Date(Date - YearStart(Date) + 2,'MMM DD') as DayWithinYear,
If you then make a chart with Year as dimension, and make a selection in DayWithinYear, then you have what you want.