Younes
Contributor

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

2 ACCEPTED SOLUTIONS

Accepted Solutions
Misbah
Moderator

@Younes

Simplest and easiest way to find out the First period of the Timescale is

OFFSET(1,-1,0) = 0

Hope that helps

View solution in original post

Misbah
Moderator

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 formulaOFFSET(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 to1然后你问Anaplan进一步推动它by1period in the second parameter. Hence the first parameter which is 1 gets pushed to subsequent periods.

Misbah_0-1591349516702.png

If you look at the overall formula nowOFFSET(1,-1,0) = 0it checks the condition and looks for a time period which has 0 in it and matches with that time period.

Misbah_1-1591349843627.png

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)

Misbah_2-1591350174103.png

Note:First Parameter doesn't necessarily has to be 1, it can be any number apart from 0

Hope that clarifies it

View solution in original post

19 REPLIES19
Misbah
Moderator

@Younes

Simplest and easiest way to find out the First period of the Timescale is

OFFSET(1,-1,0) = 0

Hope that helps

einas.ibrahim
Master Anaplanner/Community Boss

@Misbah:angry_face:

I was going to help@Younesarrive at that by himself.
Hey@Youneslet us know if you have other questions or need more explanation on this formula:smiling_face_with_smiling_eyes:

Einas
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"

Dear community members
Consider posting your question as a new topic and not in the thread of another topic/question. This help other community members to easily find the answer they looking for and doesn't cause the original thread to be so cluttered that we can't find what we are looking for
Misbah
Moderator

@einas.ibrahim

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.

Younes
Contributor

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

Misbah
Moderator

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 formulaOFFSET(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 to1然后你问Anaplan进一步推动它by1period in the second parameter. Hence the first parameter which is 1 gets pushed to subsequent periods.

Misbah_0-1591349516702.png

If you look at the overall formula nowOFFSET(1,-1,0) = 0it checks the condition and looks for a time period which has 0 in it and matches with that time period.

Misbah_1-1591349843627.png

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)

Misbah_2-1591350174103.png

Note:First Parameter doesn't necessarily has to be 1, it can be any number apart from 0

Hope that clarifies it

Younes
Contributor

Tanks a lot@Misbah, that is extremely helpful !

einas.ibrahim
Master Anaplanner/Community Boss

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.

Einas
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"

Dear community members
Consider posting your question as a new topic and not in the thread of another topic/question. This help other community members to easily find the answer they looking for and doesn't cause the original thread to be so cluttered that we can't find what we are looking for
rachelwatsky
Occasional Contributor

Thank you soooo much@Misbah, I had been stuck on this part forever!

kunal_311
Frequent Contributor

Hi@Misbah@einas.ibrahim,

难道我们需要避免硬编码的形式ulas? 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.