Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
gr_eldred
Contributor II

if in script

good night I need to add an if to this script


if weekday(today()) = 'dom' then ... else .... endif

that is, if it's Sunday, I need the script like that.

tmp_Vta_Act_6W:

LOAD %Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A') as Pto_vta,

ApplyMap('Map_Clasific_art', %Art_ID,'N/A') as Clasificación,

if ( (Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))>456

,'Mismas Tiendas'

,if(((Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))<456)

,'Nuevas'

)

) as Master_Antiguedad,

    sum(Cantidad_Estandar) as Cant_Estandar_Act6W

FROM

Modelo\Fact_Comercial.qvd (qvd)

where

Status <> 'C'

//and (Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))>=456// se Agrega calculo para mismas tiendas

and ApplyMap('Map_Calendario_Sem', Fecha,0)<=  $(vMaxValue)

and ApplyMap('Map_Calendario_Sem', Fecha,0)>= $(vMaxValue)-5

and WildMatch( ApplyMap('Map_Clasific_art', %Art_ID,'N/A'), 'Mac', 'Ipad', 'Iphone', 'Apple Watch', 'Accesorios Apple')

Group by %Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A'),

ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A'),

ApplyMap('Map_Clasific_art', %Art_ID,'N/A')

;

Store tmp_Vta_Act_6W into [..\1_QVDs\Transformación\Fact\Temp\tmp_Vta_Act_6W.qvd](qvd);

drop table tmp_Vta_Act_6W;

//Año Anterior

tmp_Vta_Ant_6W:

LOAD %Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A') as Pto_vta,

    ApplyMap('Map_Clasific_art', %Art_ID,'N/A') as Clasificación,

    if ( (Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))>456

,'Mismas Tiendas'

,if(((Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))<456)

,'Nuevas'

)

) as Master_Antiguedad,

    sum(Cantidad_Estandar) as Cant_Estandar_Ant6W

FROM

Modelo\Fact_Comercial.qvd (qvd)

where

Status <> 'C'

//and (Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))>=456// se Agrega calculo para mismas tiendas

and ApplyMap('Map_Calendario_Sem', Fecha,0)<=  $(vMaxValue)-52

and ApplyMap('Map_Calendario_Sem', Fecha,0)>= $(vMaxValue)-57

and WildMatch( ApplyMap('Map_Clasific_art', %Art_ID,'N/A'), 'Mac', 'Ipad', 'Iphone', 'Apple Watch', 'Accesorios Apple')

Group by %Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A'),

ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A'),

ApplyMap('Map_Clasific_art', %Art_ID,'N/A')

;

Store tmp_Vta_Ant_6W into [..\1_QVDs\Transformación\Fact\Temp\tmp_Vta_Ant_6W.qvd](qvd);

drop table tmp_Vta_Ant_6W;

//calculo 6 W

Let vVtaSemanaDía = date(today(), 'YYYYMMDD');

//eed: falta agregar UNA COLUMNA DE FECHA ....

tmp_vta_6Wbl$(vVtaSemanaDía):

Load

%Pto_vta_ID,

Clasificación,

date(today()) as Fecha_Master,

Cant_Estandar_Act6W

FROM

Transformación\Fact\Temp\tmp_Vta_Act_6W.qvd (qvd)

where Master_Antiguedad='Mismas Tiendas';

left join

LOAD

%Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A') as Pto_vta,

Clasificación,

date(today()) as Fecha_Master,

Cant_Estandar_Ant6W

FROM

Transformación\Fact\Temp\tmp_Vta_Ant_6W.qvd (qvd)

where Master_Antiguedad='Mismas Tiendas';

CALL QVDGenerator_Vta('Fact') ;

otherwise, it is so

tmp_Vta_Act_6W:

LOAD %Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A') as Pto_vta,

ApplyMap('Map_Clasific_art', %Art_ID,'N/A') as Clasificación,

if ( (Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))>456

,'Mismas Tiendas'

,if(((Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))<456)

,'Nuevas'

)

) as Master_Antiguedad,

    sum(Cantidad_Estandar) as Cant_Estandar_Act6W

FROM

Modelo\Fact_Comercial.qvd (qvd)

where

Status <> 'C'

and ApplyMap('Map_Calendario_Sem', Fecha,0)<=  $(vMaxValue)-1

and ApplyMap('Map_Calendario_Sem', Fecha,0)>= $(vMaxValue)-6

and WildMatch( ApplyMap('Map_Clasific_art', %Art_ID,'N/A'), 'Mac', 'Ipad', 'Iphone', 'Apple Watch', 'Accesorios Apple')

Group by %Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A'),

ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A'),

ApplyMap('Map_Clasific_art', %Art_ID,'N/A')

;

Store tmp_Vta_Act_6W into [..\1_QVDs\Transformación\Fact\Temp\tmp_Vta_Act_6W.qvd](qvd);

drop table tmp_Vta_Act_6W;

//Año Anterior

tmp_Vta_Ant_6W:

LOAD %Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A') as Pto_vta,

    ApplyMap('Map_Clasific_art', %Art_ID,'N/A') as Clasificación,

    if ( (Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))>456

,'Mismas Tiendas'

,if(((Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))<456)

,'Nuevas'

)

) as Master_Antiguedad,

    sum(Cantidad_Estandar) as Cant_Estandar_Ant6W

FROM

Modelo\Fact_Comercial.qvd (qvd)

where

Status <> 'C'

//and (Num(Today())-Num(ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A')))>=456// se Agrega calculo para mismas tiendas

and ApplyMap('Map_Calendario_Sem', Fecha,0)<=  $(vMaxValue)-53

and ApplyMap('Map_Calendario_Sem', Fecha,0)>= $(vMaxValue)-58

and WildMatch( ApplyMap('Map_Clasific_art', %Art_ID,'N/A'), 'Mac', 'Ipad', 'Iphone', 'Apple Watch', 'Accesorios Apple')

Group by %Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A'),

ApplyMap('Map_Antiguedad', %Pto_vta_ID,'N/A'),

ApplyMap('Map_Clasific_art', %Art_ID,'N/A')

;

Store tmp_Vta_Ant_6W into [..\1_QVDs\Transformación\Fact\Temp\tmp_Vta_Ant_6W.qvd](qvd);

drop table tmp_Vta_Ant_6W;

//calculo 6 W

Let vVtaSemanaDía = date(today(), 'YYYYMMDD');

//eed: falta agregar UNA COLUMNA DE FECHA ....

tmp_vta_6Wbl$(vVtaSemanaDía):

Load

%Pto_vta_ID,

Clasificación,

date(today()) as Fecha_Master,

Cant_Estandar_Act6W

FROM

Transformación\Fact\Temp\tmp_Vta_Act_6W.qvd (qvd)

where Master_Antiguedad='Mismas Tiendas';

left join

LOAD

%Pto_vta_ID,

ApplyMap('Map_Pto_vta_ID', %Pto_vta_ID,'N/A') as Pto_vta,

Clasificación,

date(today()) as Fecha_Master,

Cant_Estandar_Ant6W

FROM

Transformación\Fact\Temp\tmp_Vta_Ant_6W.qvd (qvd)

where Master_Antiguedad='Mismas Tiendas';

CALL QVDGenerator_Vta('Fact') ;

can anybody help me?

1 Solution

Accepted Solutions

Re: if in script

Attached

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

2 Replies
luismadriz
Valued Contributor

Re: if in script

Hola Eldred,

Please elaborate,

is it a simple one line like this:

if(condition , then , else)

Of a more complex one like this?

if x>0 then

LOAD * from pos.csv;

elseif x<0 then

LOAD * from neg.csv;

else

LOAD * from zero.txt;

end if

Saludos,

Luis

Re: if in script

Attached

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post