Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 help
Matthias
Hi Matthias,
I think you missed a ')' at the end of your formula and that is why it is not working.
Take this example:
Table: Load *, 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 [ ID, time, 1, 07:37:15 2, 13:13:51 3, 17:23:45 ];
This is the outcome:
Jordy
Climber
Hi Matthias,
I think you missed a ')' at the end of your formula and that is why it is not working.
Take this example:
Table: Load *, 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 [ ID, time, 1, 07:37:15 2, 13:13:51 3, 17:23:45 ];
This is the outcome:
Jordy
Climber
Hi Jordy,
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?!
Hi Matthias,
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.
Jordy
Climber