Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
marygrace
Contributor III
Contributor III

Is possible to use if statement into variable calculation?

Hi,

I am trying to use if condition into variable calculation. I need to identify if day of the week is Monday to go back 2 days until Saturday.

the expresions works well, I valideted both,  however the if condition is not working well.

if( num(weekday(Date)) = 1,

Count(

     {$

          <Date={"$(=Date(max(Date),'DD/MM/YYYY'))"}, _Id_Flag={0},Estatus_Cobranza= {'EN SURTIDO','FACTURADO','ENTREGADO','CONSOLIDADO'}, Liberado={1}, TipoDeEntrega -= {'SOLO FACTURA'},Year={$(vAñoActual)},Month=,Week=>

          +

          <Date={"$(=Date(max(Date)-2,'DD/MM/YYYY'))"}, _Id_Flag={0},Estatus_Cobranza= {'EN SURTIDO','FACTURADO','ENTREGADO','CONSOLIDADO'}, Liberado={0}, TipoDeEntrega -= {'SOLO FACTURA'},Year={$(vAñoActual)},Month=,Week=>

     }

     distinct Numero_OrdenVenta),

    

Count(

     {$

          <Date={"$(=Date(max(Date),'DD/MM/YYYY'))"}, _Id_Flag={0},Estatus_Cobranza= {'EN SURTIDO','FACTURADO','ENTREGADO','CONSOLIDADO'}, Liberado={1}, TipoDeEntrega -= {'SOLO FACTURA'},Year={$(vAñoActual)},Month=,Week=>

          +

          <Date={"$(=Date(max(Date)-1,'DD/MM/YYYY'))"}, _Id_Flag={0},Estatus_Cobranza= {'EN SURTIDO','FACTURADO','ENTREGADO','CONSOLIDADO'}, Liberado={0}, TipoDeEntrega -= {'SOLO FACTURA'},Year={$(vAñoActual)},Month=,Week=>

     }

     distinct Numero_OrdenVenta))

    

Somebody can help me?

thank you!

10 Replies
MK9885
Master II
Master II

Your Count expression would only satisfy if >>>>>> if( num(weekday(Date)) = 1,

Which means the condition has to be selected manually.


Maybe use

If(Getselectedcount(Weekday)=0, and then your condition ?


You can create Weekday field in backend

Weekday(Date) as Weekday