Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
LP27
Creator II
Creator II

Escape sequence in IF condition in Load Script.

Hi Everyone,

I am trying to enter  the below If condition in Load Script and it not working because of not using Escape Sequence.

 if(today() >= [Calendar day] , 'Week' &' '&Week([Calendar day]) &'('& Year([Calendar day])&')' )

 

Could some one tell me best way to use the above condition.

 

Thanks in advance!

Labels (3)
1 Solution

Accepted Solutions
LP27
Creator II
Creator II
Author

Your correct! 

[Calendar day]  was not read as Date properly.

Hence I used this condition -

if(today()>=date#("Calendar day",'DD.MM.YYYY'), 'Week' &' '&Week(date#("Calendar day",'DD.MM.YYYY')) &'('& Year(date#("Calendar day",'DD.MM.YYYY'))&')' ) as Week_Cal

View solution in original post

5 Replies
TimvB
Creator II
Creator II

Assuming you need to create an extra field by using the if statement, if so, you need to drop the "=" character and use something like below:

TableName:

Load

[YourFields],

if(today() >= [Calendar day] , 'Week' &' '&Week([Calendar day]) &'('& Year([Calendar day])&')' ) as [New Field]

From <YourSource>;

 

Otherwise, please provide a clear explanation, i.e., the purpose, your expectation, sample dataset, etc.

sunny_talwar

Can you share a script where this doesn't work? I don't see a need for escape sequence here.

LP27
Creator II
Creator II
Author

Sunny,

I am trying to create date field "Calendar Day"  into columns as week in Pivot table like shown below -

Week 1(2020)Week 2(2020)Week 3(2020)Week 4(2020)

 

If I use the below condition in front end of scripting its working fine, but that slows down the table when loaded.

 if(today() >= [Calendar day] , 'Week' &' '&Week([Calendar day]) &'('& Year([Calendar day])&')' )

So now I want to use this condition in load Script, when I use the above condition in Load script. It appears as -

Week()

 

and it sums all week.

So I thought escape sequence can act well in this case.

 

 

sunny_talwar

I am not seeing any issues with your script... is you field [Calendar day] read as date?

LP27
Creator II
Creator II
Author

Your correct! 

[Calendar day]  was not read as Date properly.

Hence I used this condition -

if(today()>=date#("Calendar day",'DD.MM.YYYY'), 'Week' &' '&Week(date#("Calendar day",'DD.MM.YYYY')) &'('& Year(date#("Calendar day",'DD.MM.YYYY'))&')' ) as Week_Cal