Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
How do I compare the same dates in different years on a line chart? I would like to display two lines, one for 2020 and one for 2021 for comparison, not one line as in the attached screenshot.
Thanks,
/Staffan
@Staffan if I understood correctly
you have or you add in script Day(Date) as DAY and year(Date) as YEAR
in the UI
dimension DAY
measures:
1->=Sum({<YEAR = {"$(=Max(YEAR))"} >} Visits)
2->=Sum({<YEAR = {"$(=Max(YEAR)-1)"} >} Visits)
Yes, here is how it looks now in my UI:
My goal is to compare -day by day- the month of april 2020 with the month of april 2021. Maybe I would be better off restructuring my data set, but it would be interesting to see if it can be solved with this type of data.
@Staffan in dimension change DATE.DATE to =day(DATE.DATE)
do you have a YEAR field in your data model ? if not you can create in your script
something like
1->=Sum({<DATE.YEAR= {"$(=Max(DATE.YEAR))"} >} Visits)
2->=Sum({<DATE.YEAR= {"$(=Max(DATE.YEAR)-1)"} >} Visits)
I only have two columns: Date and Visits. Like this:
And I have added your two suggestions as measures:
@Staffan or you can change measure to :
1-> =Sum({<Date = {">=$(=Max(YearStart(Date))) <=$(=Max(Yearend(Date)))"} >} Visits)
2->=Sum({<Date = {">=$(=Max(Addyears(YearStart(Date),-1))) <=$(=Max(Addyears(YearEnd(Date),-1)))"} >} Visits)
Almost there 🙂 It looked like it worked for a second, then the layout changed to this:
Oh yes its me
can you share a sample data in excel format or csv
Yes, here you go