Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Compare Sales of Selected Days vs previous year days (same week, same weekday) ? (1)

Hi,

I would like to know how to implement Sales comparison by day.

Selected days compared to the corresponding day from previous year.

Same week, same weekday, previous year.

i've done it with : = sum( { 1< WeekDay= {'$(= weekday(Max(%DateKey) ))'} , WeekNumber= {'$(=week(Max(%DateKey)))'}, Year= {'$(=year(Max(%DateKey))-1)'} > } Sales).But i only got the last day.

How can i have a chart (Table) with the corresponding days as Dimension of the chart and the sales (two compared days) as expressions ?

Thanks.

Seydou from Senegal (West Africa)

7 Replies
Not applicable
Author

No idea ?

Not applicable
Author

You can create a dimension of the same week day of the previous year:

MakeWeekDate(year(Date)-if(WeekYear(Date)= year(Date),1,0), Week(Date), WeekDay(Date)) as SameWeekDayPreviousYear

I hope you find this useful!

Not applicable
Author

Sorry, I made a mistake in my logic when you select a first week of the year or the last one. But here you have the fix:

MakeWeekDate(year(Date)-if(WeekYear(Date)> year(Date),0,if(WeekYear(Date)< year(Date),2,1)), Week(Date), WeekDay(Date)) as SameWeekDayPreviousYear

beristardj
Creator
Creator

good day.

I take same problem.

In my case, i try build more dimensions

date(fechador ) as Fecha,
fechador as Fechador,
Day( date(fechador )) as Dia,
Month( date(fechador )) as Mes,
Year( date(fechador )) as Año,
WeekDay( date(fechador )) as DiaSemana,
Week( date(fechador )) as Semana,
Dual(Num( Week( date(fechador) )),'00')&' '&WeekDay( date($(fechador) )),fechador) as SemanaDia,
Week(date(fechador) )) & '/' & WeekYear(date($(fechador) )) as Otrasemana
Resident TableWithDate ;

After reload, you can try with diferents combinations fields within, results are for some interest.

i hope this seve for you.

tobias_klett
Partner - Creator II
Partner - Creator II

Hi,
if your expression sum(sales) is for this year and %DateKey contains your single date, Then use this expression for last year:
sum( {<%DateKey={'$(=addyears(%DateKey,-1))'}>} sales)

Hope this helps

marcelo_7
Creator
Creator

Just so you know. This will not work for all cases.
Example:
2011-01-01 gives 2009-12-26
2010-01-04 gives 2008-12-29

marcelo_7
Creator
Creator

With years having 53 weeks sometimes i think it's hard to make all dates work. What I did was subtract a year and then add days until I get to the same weekday as the current year.
date(if(weekday(date)-weekday(AddYears(date, -1))>0, addyears(date, -1) +(weekday(date)-weekday(AddYears(date, -1))), addyears(date, -1)+(7-weekday(date)-weekday(AddYears(date, -1)))))