Skip to main content
Announcements
Join us on Sept. 17 to hear how our new GenAI Assistant empowers data professionals: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
RafaelLucasdaCosta
Contributor II
Contributor II

Compare current day with same weekday last year within the same chart

Hello everybody. First I will explain my problem. I need to create a bar chart that shows daily sales for a selected month. On the same chart I want to display sales for the same month last year. The problem is that I was asked to compare the dates on the same day of the week, I'll give you an example.
The current day is 7/26/2021 (Monday). Naturally the same day of the month last year would be 7/26/2020 (Sunday). But what I need to display is the equivalent day of the week value, that is, my equivalent day last year = 6/27/2020 (Monday).
And here are my questions.
Is it possible to do this in a bar chart?
Is it possible to do this through set analysis?

I tried to do it by set analysis, but the expressions got confused and started to give a zero or '-' result. I'm new to Qlik Sense so I might be missing something.
I will attach a photo of what my chart looks like. The bars are the current year's sales and the red marker is the last year's dates. (In case they don't consider the day of the week yet). In this same chart I also have a line indicating how much I achieved in relation to the daily sales target. (For this indicator I do not need to make comparisons with last year). Thanks in advance!

Labels (1)
2 Replies
MayilVahanan

hi

Try like below

Dim: WeekDay

Exp: sum({< Year={$(=Year(Max(Date))-1)},Week={$(=Week(Max(Date)))},WeekDay={'$(=weekday(Max(Date)))'}>}Sales)

It will compare the last year same week day

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
RafaelLucasdaCosta
Contributor II
Contributor II
Author

Hi @MayilVahanan . Your expression works correctly in a chart with the days of the week. But it doesn't solve my problem. In my chart I need to display the Day dimension, which corresponds to the day of the month. I need to compare it to last year on the same day of the week. Let's say my current date is 7/27/21 which is a Tuesday. My day of the week last year corresponding to the same Tuesday of the month is 7/28/20. This is the information I intend to display. Take a look at the attached image, in it is the graphic I want to display. The bars correspond to sales on the days of the selected month. The red markers should match the same day of the week as last year. So on the first day I would have as last year's marker the value that corresponds to day two, as it is the same day of the week. This would be repeated every day of the month. Is it possible to create a chart this way?