TIMST Issue

Post Reply
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

TIMST Issue

Post by ViRa »

Hi all,

I'm trying to quit a chore when a condition of combination of date/time is achieved. To do this, I'm using the TIMST function. The code I added in the Prolog tab is -

Code: Select all

#v1=SUBST(TODAY,7,2);
v1=DAY(TODAY);
v2=TIMST(v1, '\H\p \imin\ssec');
If(v2<>11, '2p.m. 45min00sec');
ChoreQuit;
Endif;
However, I'm getting the error as attached -

Can somebody please let me know the issue with my syntax here? I'd appreciate your time and efforts.

Thanks
Attachments
Error on compiling the process
Error on compiling the process
TIMST.JPG (29.75 KiB) Viewed 8105 times
Wim Gielis
MVP
Posts: 3241
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: TIMST Issue

Post by Wim Gielis »

Hello

I can honestly assure you, it helps to press F1 in a Turbo Integrator process, and search for Timst.
If you would do that, you could see that Timst returns a string.
Hence, among other things, <> will need to be replaced with @<> in your comparison.
Did you check the popup with the error? It's usually (not always) helpful.
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: TIMST Issue

Post by ViRa »

Thanks Wim for the reply. I did try adding @<> before posting this thread. However, even that throws an error - 'Incorrect logical comparison'. To convert all the parameters within the If condition to string, I did try substituting v1 as 'v1=SUBST(TODAY,7,2);' as I assume this would return a string value as compared to 'v1=DAY(TODAY);' which would return a numeric. The updated code I tried was as below -

Code: Select all

v1=SUBST(TODAY,7,2);
#v1=DAY(TODAY);
v2=TIMST('v1', '\H\p \imin\ssec');
If(v2@<>11, '2p.m. 45min00sec');
ChoreQuit;
Endif;
Despite this, the process throws error.

Alternatively, I also tried TIMVL which returns numeric using the below code. But no success here either.

Code: Select all

v1=DAY(TODAY);
v2=TIMVL(v1, 'H:I:S');
If(v2<>(11, '15:05:00'));
ChoreQuit;
Endif;
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: TIMST Issue

Post by Alan Kirk »

ViRa wrote:Thanks Wim for the reply. I did try adding @<> before posting this thread. However, even that throws an error - 'Incorrect logical comparison'. To convert all the parameters within the If condition, I did try substituting v1 as 'v1=SUBST(TODAY,7,2);' as I assume this would return a string value as compared to 'v1=DAY(TODAY);' which would return a numeric. The updated code I tried was as below -

Code: Select all

v1=SUBST(TODAY,7,2);
#v1=DAY(TODAY);
v2=TIMST('v1', '\H\p \imin\ssec');
If(v2@<>11, '2p.m. 45min00sec');
ChoreQuit;
Endif;
Despite this, the process throws error.
First, you're comparing v2 (which, as Wim noted, returns a string) with a numeric value, not a string.
Second, I'm not sure what you're expecting the second argument of your If() statement to do but in this context (there are two permutations of If() in TI (the TI flow control block and the Rules function) and this is neither of them) it requires one argument not two, and the argument needs to evaluate to either True or False.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
Duncan P
MVP
Posts: 600
Joined: Wed Aug 17, 2011 1:19 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2
Excel Version: 2003 2007
Location: York, UK

Re: TIMST Issue

Post by Duncan P »

So the numeric comparison is not the only problem.

IF has two forms

Code: Select all

IF ( condition );
...
ENDIF;
and

Code: Select all

var = IF( condition, value_if_true, value_if_false );
You have something between with

Code: Select all

IF( condition, string );
...
ENDIF;
However thinking laterally it is possible that you meant

Code: Select all

IF( v2 @<> v1 | '2p.m. 45min00sec');
where the | is the string concatenation operator and you use v1 instead of 11.

[EDIT] Wow. We are all piling in today!
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: TIMST Issue

Post by ViRa »

Thanks Alan and Duncan for your inputs. I'm yet to rectify the If condition as per your suggestion. Actually I'm trying to write a condition to quit running a chore if the day and time combination is not as per the requirement. To do this, I tried the below code.

Code: Select all

If((DAY(TODAY)<>11) & (TIME)@<>'14:01');
ChoreQuit;
Endif;
However, I noticed that the If condition is not taking the 'Time' part into consideration. That is, if I set the chore to run every hour or minute, it runs as soon as the 'Day' condition is met at any time. Hence I thought of trying a function that returns date and time together and ended up with TIMST.

Could you please guide me as to why the below code is not working either? I will improvise accordingly.
Thanks.
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: TIMST Issue

Post by Alan Kirk »

ViRa wrote:Thanks Alan and Duncan for your inputs. I'm yet to rectify the If condition as per your suggestion. Actually I'm trying to write a condition to quit running a chore if the day and time combination is not as per the requirement. To do this, I tried the below code.

Code: Select all

If((DAY(TODAY)<>11) & (TIME)@<>'14:01');
ChoreQuit;
Endif;
However, I noticed that the If condition is not taking the 'Time' part into consideration. That is, if I set the chore to run every hour or minute, it runs as soon as the 'Day' condition is met at any time. Hence I thought of trying a function that returns date and time together and ended up with TIMST.

Could you please guide me as to why the below code is not working either? I will improvise accordingly.
Thanks.
I can take a look at that but I think you may have the cart and horse in opposing directions.

If that's the condition that you want then rather than having the chore bang away every hour or every minute (which causes unnecessary overhead), why not have it run daily at 14:01 and simply test for the Day() condition? This will also avoid the situation of any other long running processes delaying the start of the chore, pushing it past 14:01, in which case it won't run at all for that month. (And yes, TI should allow you to schedule a chore on a specific day of month as well as being a lot more flexible generally rather than still being stuck in the '90's. Don't hold your breath, though.)
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: TIMST Issue

Post by ViRa »

why not have it run daily at 14:01 and simply test for the Day() condition?
Alan, to run daily at 14:01, should I set the hours to 14 and minutes to 01? Apologies if I'm wrong, but I'm not aware of scheduling at a particular time.
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: TIMST Issue

Post by Alan Kirk »

ViRa wrote:
why not have it run daily at 14:01 and simply test for the Day() condition?
Alan, to run daily at 14:01, should I set the hours to 14 and minutes to 01? Apologies if I'm wrong, but I'm not aware of scheduling at a particular time.
No, you set the start time as 14:01 and the cycle as 1 day.

Be careful to set the start date in the same Daylight Savings season as the one that you're currently in because otherwise it will shift by 1 hour. If you set it to today's date you'll be OK, but every time you move on or off daylight savings you'll need to update the schedule. That's user-friendliness, IBM style.

Will post an explanation of why your If() function didn't work in a few minutes.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: TIMST Issue

Post by ViRa »

Alan, thank you so much...it worked!I tried scheduling now and it ran just once for the said time and did not run thereafter unlike last time where I had scheduled it to run every minute and my log file was growing by every minute... not to mention how it stopped other processes from running! Thanks again. So I'm hoping it would not run tomorrow as I have the day condition set on Prolog to check for day <>11.

I shall look forward to your explanation on the initial If() that I wrote.
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: TIMST Issue

Post by Alan Kirk »

ViRa wrote:

Code: Select all

If((DAY(TODAY)<>11) & (TIME)@<>'14:01');
ChoreQuit;
Endif;
Now to the reason that this doesn't work, and why "negative conditions" can sometimes blind you to the reason:

The If() condition has to be either True or False as a whole. Because you've used an AND operator, for the entire IF() condition to be True, both of the sub-components must also be True.

Most days (DAY(TODAY)<>11) will be True. But here's the first gotcha; on every day of the month there will be one minute, specifically 14:01, where (TIME)@<>'14:01' will be False. As a result the expression as a whole will be False and the ChoreQuit will not be executed. In other words, that condition will actually have the chore continuing each day at 14:01, assuming that you had it on a 1 minute cycle and that the start of it wasn't delayed by another process.

The reverse occurs on the 11th. (DAY(TODAY)<>11) will always evaluate to False on that day, therefore the entire expression evaluates to False (remembering that for it to be True, both components must be True), therefore the ChoreQuit command will never be executed on the 11th. Consequently the chore continues to run, regardless of what the time is.

To have it work, and remember that I'm merely talking about the logic here, not recommending that you do this), you would need to break it out into two separate tests; one to test for the day, and then one to test for the time on the prescribed days. Like so:

Code: Select all

If( DAY(TODAY)<>11);
    #Quit if the day is not the 11th.
    AsciiOutput('F:\Temp\TimeExample.txt','Quitting Condition 1', TIME);
    ChoreQuit;
ElseIf( TIME@<>'14:01');
    # If this block is reached the day must be the 11th.
    # Therefore we test for the time only.
    AsciiOutput('F:\Temp\TimeExample.txt','Quitting Condition 2', TIME);
    ChoreQuit;
Endif;

AsciiOutput('F:\Temp\TimeExample.txt','Continuing', TIME);
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
ViRa
Regular Participant
Posts: 155
Joined: Tue May 14, 2013 1:53 pm
OLAP Product: Cognos BI, TM1
Version: 9.5.2 - 10.1.1
Excel Version: Excel 2003

Re: TIMST Issue

Post by ViRa »

Thanks Alan for your valuable guidance. It makes so much sense to me now.
Post Reply