Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Start week on thursday

Hello, QlikView gurus.

We're currently working on a proyect, and we have an inconvinient because the way our clients are handling their weeks. Their weeks start oficially on thursday, and end on wednesday. For example, their week 23 started on May 31, and enden on Jun 6.I'm trying to modify my master calendar using the Weekstart funcion, but i don't know the correct syntax, or a good way to use it. Could enyone help me to modify the calendar script, or at least orient me in this one?

Here's the script i'm using for the master calendar:

Min_Max_Fechas:

LOAD date(min(%Fecha),'DD/MM/YYYY') as Min_Fecha,

date(max(%Fecha),'DD/MM/YYYY') as Max_Fecha

RESIDENT TRANSACCIONES;

LET vMinFecha = num(peek('Min_Max_Fechas.Min_Fecha',0,'Min_Max_Fechas')) ;

LET vMaxFecha = num(peek('Min_Max_Fechas.Max_Fecha',0,'Min_Max_Fechas'));

CALENDARIO:

LOAD Date(TRANSACTION_DATE, 'DD/MM/YYYY') as %Fecha,

Year(TRANSACTION_DATE) as Año,

Month(TRANSACTION_DATE) as Mes,

Day(TRANSACTION_DATE) as Dia,

DayName(TRANSACTION_DATE) as DiaNombre,

MonthName(TRANSACTION_DATE) as Periodo,

num(MonthName(TRANSACTION_DATE)) as NumPeriodo,

week(TRANSACTION_DATE) as Semana,

'S' & Ceil(Month(TRANSACTION_DATE)/6) as Semestre,

'Q' & Ceil(Month(TRANSACTION_DATE)/3) as Trimestre

WHERE Year(TRANSACTION_DATE) > $(vMinYear);

LOAD

date($(vMinFecha) + recno() - 1) as TRANSACTION_DATE

AUTOGENERATE ($(vMaxFecha) - $(vMinFecha) + 1);

Drop table Min_Max_Fechas;

PD: vMinYear is a simple variable. Currently, is set to 2006

Thanks in advance!!!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

emachado,

it probably depends on how your customer defines the handling of the week numering on year changes.

If it's all about a shift in week start, but week numbering is taken from the common QV / ISO week numbering, you could try also

=week(weekstart(TRANSACTION_DATE,1,3)) as Semana

View solution in original post

2 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

Try this for week

LunarWeekName(TRANSACTION_DATE, 0, 5)

Celambarasan

swuehl
MVP
MVP

emachado,

it probably depends on how your customer defines the handling of the week numering on year changes.

If it's all about a shift in week start, but week numbering is taken from the common QV / ISO week numbering, you could try also

=week(weekstart(TRANSACTION_DATE,1,3)) as Semana