Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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)
No idea ?
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!
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
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.
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
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
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)))))