If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.
Hi,Quick question. I want to define a "Morning Peak" and an "Afternoon Peak" from 7 AM to 9 AM respectively 15 AM to 17 AM.
If(Hour(PlanDepTime)>=7 AND Hour(PlanDepTime)=<9,'MorningPeak',If(Hour(PlanDepTime)>=15 AND Hour(PlanDepTime)=<18,'AfternoonPeak','NoPeak')
The format of PlanDepTime is hh:mm:ss
But in the code QlikSense does not read the AND as a Function and therefore does not except the formula.What am I doing wrong here?
Thank you very much for your helpMatthias
I think you missed a ')' at the end of your formula and that is why it is not working.
Take this example:
If(Hour(time)>=7 and hour(time)<=9,'Morning peak',IF(Hour(time)>=15 and hour(time)<=18,'Afternoon peak','No peak')) as Category
Load * Inline [
This is the outcome:
View solution in original post
thank you for your reply.
Your were right, but even when adding the 1 missing right parenthesis it still tells me that there is one missing. I can add another 3 parenthesis and it still tells me the that there is a right parenthesis missing?!
I would advice you to do this in the back-end (read script). This is easier because you can then add this as a dimension itself.
Copy my formula and fill in 'PlanDepTime' instead of 'time'.
If you are still planning of doing this in the front-end, create a measure (not dimension!) and copy my formula and fill in 'PlanDepTime' instead of 'time'. This should also work.