Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
ale_nilo84
Contributor
Contributor

Function Weekname

Dear Sirs, I have stated the following script and I need to do a calculus with last week data.


fechas:
LOAD Distinct
fecha_union,
year (fecha_unionas Año,
Month (fecha_unionas Mes,
day(fecha_union) as Dia,
MonthName (fecha_unionas Periodo,
Num#(date (fecha_union, 'YYYYMM'))  as PeriodoNum,
Week(fecha_union) as Semana,
Weekname(fecha_union) as Numero_Semana,
date(fecha_unionas fecha
Resident union;


I stated the following variables

vSemanaMax= Max(Numero_Semana

vSemanaMax_m1 = Max(Numero_Semana)-1


Then the following expression, gives me a null result


sum({<Año=, Mes=, fecha=, PeriodoNum=, Numero_Semana={$(vSemanaMax)}>}numerador_icf) / sum({<Año=, Mes=, fecha=,PeriodoNum=, Numero_Semana = {$(vSemanaMax)}>} denominador_icf)

null.jpeg

   Where is the problem?

   Thanks in advance

1 Solution

Accepted Solutions
sunny_talwar

May be add your variable within single quotes like this and add = sign within the dollar sign expansion

Sum({<Año=, Mes=, fecha=, PeriodoNum=, Numero_Semana={'$(=vSemanaMax)'}>}numerador_icf) /Sum({<Año=, Mes=, fecha=,PeriodoNum=, Numero_Semana = {'$(=vSemanaMax)'}>} denominador_icf)

View solution in original post

5 Replies
sunny_talwar

Try your variables like this

vSemanaMax= WeekName(Max(fecha_union));

vSemanaMax_m1 = WeekName(Max(fecha_union)-7);

ale_nilo84
Contributor
Contributor
Author

Ok I changed the variables, now it appears this following error.

null2.jpeg

Should I fix the expression?

sum({<Año=, Mes=, fecha=, PeriodoNum=, Numero_Semana={$(vSemanaMax)}>}numerador_icf) /sum({<Año=, Mes=, fecha=,PeriodoNum=, Numero_Semana = {$(vSemanaMax)}>} denominador_icf)

sunny_talwar

May be add your variable within single quotes like this and add = sign within the dollar sign expansion

Sum({<Año=, Mes=, fecha=, PeriodoNum=, Numero_Semana={'$(=vSemanaMax)'}>}numerador_icf) /Sum({<Año=, Mes=, fecha=,PeriodoNum=, Numero_Semana = {'$(=vSemanaMax)'}>} denominador_icf)

ale_nilo84
Contributor
Contributor
Author

Great!!, it works fine now,

What is the function of the single quotes?

sunny_talwar

You will be able to find all the information here:

A Primer on Set Analysis