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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
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

Labels (1)
1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

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

View solution in original post

6 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

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
MVP
MVP

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

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

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
Author

Hey Mayil,

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

QV rocks !!!!

Regards

cesaraccardi
Specialist
Specialist

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
Partner - Specialist
Partner - Specialist

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)