Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Condition on set Analysis

Hi,

I´ve this expression:

 

COUNT( {$<NR_FATO={3}, CD_MOTIVO={10,31}>} CHAVE)

The dimension is a DATE. My trouble is, when DATE IS WEEKEND, i have tu use CD_MOTIVO={31}.

When DATE is a normal day (MOnday, Tuesday.... friday) i have to use CD_MOTIVO={10}.

Thank you

1 Solution

Accepted Solutions
celambarasan
Not applicable

Re: Condition on set Analysis

Create a Field to denote a weekend flag and make expression as

Lets say If weekEnd then 1 else 0

COUNT( {$<NR_FATO={3}, CD_MOTIVO={10}, IsWeekEnd={0}>+<NR_FATO={3}, CD_MOTIVO={31}, IsWeekEnd={1}>} CHAVE)

Hope it helps

Celambarasan

6 Replies
celambarasan
Not applicable

Re: Condition on set Analysis

Create a Field to denote a weekend flag and make expression as

Lets say If weekEnd then 1 else 0

COUNT( {$<NR_FATO={3}, CD_MOTIVO={10}, IsWeekEnd={0}>+<NR_FATO={3}, CD_MOTIVO={31}, IsWeekEnd={1}>} CHAVE)

Hope it helps

Celambarasan

mayilvahanan
Not applicable

Re: Condition on set Analysis

HI

Try like this

=if(wildmatch(DATE,'Sunday','Ssaturday'),COUNT( {$<NR_FATO={3}, CD_MOTIVO={10}>} CHAVE),COUNT( {$<NR_FATO={3}, CD_MOTIVO={31}>} CHAVE))

or

if(Date = 'Sunday' or Date ='Saturday',COUNT( {$<NR_FATO={3}, CD_MOTIVO={10}>} CHAVE),COUNT( {$<NR_FATO={3}, CD_MOTIVO={31}>} CHAVE))

Hope it helps

Not applicable

Re: Condition on set Analysis

Hi,

Try:

if(wildmatch(DATE,'sat*','sun*'),COUNT( {$<NR_FATO={3}, CD_MOTIVO={31}>} CHAVE),

COUNT( {$<NR_FATO={3}, CD_MOTIVO={10}>} CHAVE))

Regards

Not applicable

Re: Condition on set Analysis

Hey Mayil,

i think in the meantime while i was writing the solution u had already posted

QV rocks !!!!

Regards

cesaraccardi
Not applicable

Re: Condition on set Analysis

Hi João,

I have an idea for you, you could make a verification for weekends like this:

if(

     WeekDay(DATE) = 5 or WeekDay(DATE) = 6,

     COUNT( {$<NR_FATO={3}, CD_MOTIVO={31}>} CHAVE),

     0

)

+

if(

     WeekDay(DATE) <> 5 and WeekDay(DATE) <> 6,

     COUNT( {$<NR_FATO={3}, CD_MOTIVO={10}>} CHAVE),

     0

)

The values 5 and 6 are for Saturday and Sunday. I don't know if this is the best solution, probably not but may help you to workaround.

Regards,

Cesar Accardi

brijesh1991
Not applicable

Re: Condition on set Analysis

Set a  variable weekEnd values 1 or 0

COUNT( {$<NR_FATO={3}, CD_MOTIVO={10}, IsWeekEnd={0}>+<NR_FATO={3}, CD_MOTIVO={31}, IsWeekEnd={1}>} CHAVE)