Language for finding a function to relate two tables

44 Views Asked by At

I have two tables

Fiscal period contains the numbers 1-12 Actual period contains the same sequence

However, they are related so that

Fiscal Period 1 = Actual Period 4

and

AP 1 = FP 10

I'm looking for either a formula to convert the number, or the terminology so I can properly search google. More out of curiosity than anything really

A logical way to put it would be AP=IF(FP>=10, |True|FP-9, |False| FP+3)

As a visual aid:

FP-Period Name-AP

1 = April = 4

2 = May =5

3 = June =6

4 = July = 7

5 = August = 8

6 = September = 9

7 = October = 10

8 = November = 11

9 = December = 12

10 = January= 1

11 = February = 2

12 = March = 3

1

There are 1 best solutions below

0
On BEST ANSWER

You can use the modulo operator.

if $n=aq+r$ with $n,a,q,r\in\mathbb{Z}$, then we say $n\equiv r\mod q$

This returns a value in $\{0,\dots,q-1\}$.

So $(FP+3)\mod12$ almost works, expect for December returns $0$.

To fix this, we can split the $+3$ into two bits:

$$AP=(FP+2)\mod12+1$$