Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
tomf122
Contributor III
Contributor III

IF with And Operator

I am creating an If statement which is connected to a variable and having trouble getting it to run. 

I could get it to run when i had just the Day set to Monday but when i tried to add the shift time i am keep getting 0 as a result. Is there a different way i should be approaching this from.  I want to see the number of MVT which occur's on a Monday and at those shift hours.


if(vdaydropdown = 'Monday' and MATCH(SHIFT_HOUR,'07','08','09','10','11','12','13','14'),
Count({< entry_day = {'Monday'} , SHIFT_HOUR = {'07','08','09','10','11','12','13','14'}>} MVT))

Labels (2)
11 Replies
Or
MVP
MVP

It looks as though in both cases you're just showing data for a single day, in which case, using the entry_day  field as a filter would probably be cleaner than using a variable, though of course the latter approach also works. As a personal preference, I would also create a table translating the hours into shifts (you can do this using an inline load or formula) and then use the shift for filtering, rather than matching hours each time. Once again, this works in both ways, but I tend to prefer the cleaner Shift = {'Day'} to the more complex Match(Hour,7,8,9,10,...) myself.

tomf122
Contributor III
Contributor III
Author

Yes i will take on your advice and create a table to translate into shift hours. This will make it cleaner and should make it easier for anyone else to understand if they try and adjust charts in the future. Thanks for all your help.