Level 2 Sprint 3 INV01 - Not 1st week of Timescale?
Hello,
I used the "NOT INPERIOD(CURRENTPERIODSTART())" formula to calculate to determine if it's the first week of the time scale or not and it's working. But i know that if we change the current period my formula doesn't not work anymore. I couldn't find a formula that targets the start of time scale and not the current period. Could you help me ? @einas.ibrahim
Thank you
Younes
Comments
-
-
Apologies.
Usually I don't share the formula esp with Level 3 aspirants but for Level 2 & Level 1 I help them in creating SYS Modules only.
2 -
Hello @einas.ibrahim @Misbah
Thank you for your help. I'd like to understand more the formula. How does Anaplan know with this formula that we are talking about the Time scale whe writing OFFSET(1,-1,0) ?Younes
0 -
Sure!!
First let's try to understand what OFFSET does? It basically Pulls or Pushes the numbers across the timescale. There are three parameters that are needed in the Syntax
OFFSET(x,n,z) where x is the source line item to offset
n is the offset value
z is fill value if the result is outside the timescale
Result matches the data format of x - meaning it can be number, boolean or anything else.
FORMULA: OFFSET(1,-1,0) = 0
If you take a look at the left hand side of the formula OFFSET(1,-1,0) it basically throws an output of 1 in all the time periods except the first time period. That is because you are hard coding your first parameter to 1 and then you are asking Anaplan to Push it further by 1 period in the second parameter. Hence the first parameter which is 1 gets pushed to subsequent periods.
If you look at the overall formula now OFFSET(1,-1,0) = 0 it checks the condition and looks for a time period which has 0 in it and matches with that time period.
Now Let's take a look at Second parameter. Here the ask was to find out the first period of the timescale hence second parameter was kept -1. If the ask is to find out first 3 periods of the timescale you can change the second parameter from -1 to -3 ( Its minus because we have to push the values to subsequent periods)
Note: First Parameter doesn't necessarily has to be 1, it can be any number apart from 0
Hope that clarifies it
24 -
Hey @Younes
Here is how I translate "my command" OFFSET(1,-1,0)"Please Mrs. Engine - Yes the Anaplan engine is a she- offset or move the number 1, by 1 prior position (-1) from each period you calculate, and when you can't go back any further let me know by returning a 0"
Since what we need is to determine 1st week (or not), a function like OFFSET is useful because it is bound by the model timescale. It acts in a certain way within the timescale and acts differently otherwise (in this case returns 0). We use this behavior to capture the time period when the formula acts differently - the 1st period.
12 -
Thank you soooo much @Misbah , I had been stuck on this part forever!
0 -
Hi @Misbah @einas.ibrahim ,
Shouldn't we need to avoid hard coding in the formulas? I mean that's what training teaches us.
Is that the only way to find out the first week's condition?
Just trying to understand.
0 -
In the training module, we have created NOT 1st week of time scale? line item in SYS01 tym settings by week module. So why we are trying to find out first week of timescale using OFFSET function?
IF NOT 1st week of time scale? PREVIOUS (Ending Inventory of previous week) ELSE DAT01 Beginning Inv Module.Beginning Inventory
Does this formula not serve the purpose?, finding my way for how to get ending inventory line item for the previous week.0 -
Hi @kunal_311,
Let me answer your "hard coding" question first. There is no hardcoding in OFFSET(1,-1,0). Generally speaking, hardcoding is when you write a value that will change over time or product,....etc. For Example FY19 or IF Product.Product item = Apples.
In this OFFSET formula, none of the values will be obsolete or irrelevant regardless or changes in Time. As a matter of fact, this formula will continue to work even when the Time Range changes, For example when we move to the next planning year FY21
Now to your second question, I am not sure what are you asking exactly? The OFFSET formula is the formula we are using in SYS01 to determine the first week (or not the 1st week), We then reference this line item in our Inventory Ending formula in INV01.
2 -
Apprciate your efforts to make newbies like us to understand the concepts:
1) Understood the hardcoding part.
2) I mixed it with the formula to be used in INV01 and that with SYS01. Even I used "NOT Current period?" as my formula which after reading your explanation on why we need to use OFFSET Instead of CURRENTPERIOD, It makes more sense. so changed it now.
0 -
Hey @kunal_311
I'm always happy to help.
I hope you realized why CurrentPeriod is not suitable. Current period changes - ideally every period. So while CurrentPeriod may be the same as the first period on the time scale - say on Jan 01, 20XX- once the current period moves to Feb, it is no longer the same as the first period of the time scale.
Keep on Anaplanning
2 -
Just one last point i want to understand, when we use offset function & we shift the weeks which are not 1 st week, but after offset why we need to provide =1 ?
OFFSET(x,n,z) = 10 -
Hey @kunal_311
On the semantics side .....
The Not 1st week? is of data type Boolean, right?
which mean any formula we right in this line item should return a Boolean (True or False)
The OFFSET(x,y,z) function returns the same format of the argument x
In the case of OFFSET(1,-1,0), x = 1 which is a number. so just writing OFFSET(1,-1,0) will return a number not a boolean, and will not be accepted.
On the logic side..
You need to know if the function succeeds in moving the 1 (x), -1 periods (y) and in that case, it returns the value 1, or fails (because it's at the beginning of the time scale and there is no prior period) and in this case, it returns the default value 0(z)
You need an expression that resolves to either TRUE or FALSE.
so you compare the returned value of the OFFSET function with either 1 or 0 it's your choice.
In the case of the first period
Does OFFSET(1,-1,0) = 1 ? No, this is FALSE, because the formula returns 0
2 -
Thanks a lot for your explanation. What if I would like to find the first week of each year? As I understand, the OFFSET formula only finds the first week of the time range.
Thanks,
Xin
0 -
Hey Misbah,
This was a brilliant explanation for the OFFSET function.
However, I don't clearly understand how to enable 'End users to manually select the first week in FY20'. Could you please help me with this ?
Regards
0 -
Hi @Misbah,
I am wondering if you can tell me something utterly basic for my sanity check. When people say "time period" or "time scale", it is the Time Range indicated as per:
The model calendar is as per below. Ans the timescale is from Current Fiscal Year + Number of Past Year to Current Fiscal Year + Number of Future Year as per below:
Starting time for the timescale, in this case, is 29/Dec/2019 as there is no Past Year Number and the Ending time 26/Dec/2021 (Or whatever works out as the last week of the FY21) as the Number of the Future Year is 1.
Therefore, what you suggest works as it only needs to identify as the only first week of the entire timescale (the 2 FYs) needs to be identified.
0