Skip to main content

Hi All,

I am working on requirement where the calculation involves a multiplier to be applied on previous years based on year for which it is calculated. Please see screenshot below.

I want to achieve the result in B to be dynamic, so it can be calculated until whichever year user decides it needs to stop. Currently I have achieved this by manual multiplier & Select function on Year to offset, but this is limited to years based on offset I define in formula.

'Metric A' + 'Metric A'[Select: Year-1]*2 +  'Metric A''Select: Year-2]*3 + 'Metric A''Select: Year-3]*4 + 'Metric A''Select: Year-4]*5 

Please advise, if there is a way to make this dynamic.

Thanks

Hi ​@Apurv ,

A possible solution to achieve your goal is to create a technical dimension that helps simulate the loop logic. Here's a detailed step-by-step breakdown:

Step 1: Create a Technical Dimension

Start by creating a dimension (e.g., ID10) that has the same number of items as your Year dimension. This will be used to simulate the loop.

Define the following properties:

  • Name: Integer — generated automatically by Pigment.

  • Reverse ID: Integer — calculated with this formula:

    ID10.Name1REMOVE MAX: ID10] - ID10.Name + 1

    This flips the rank of each item to get the reverse order.
     

    ID10 dimension

     

Step 2: Create a Matching Metric (Rank A)

Build a metric Rank A (data type: dimension ID10) that maps each Year item to a corresponding item in the ID10 dimension using the following formula:

MATCH(
Cumulate(IFDEFINED(A, 1), Year),
ID10.Name
)

This links each year's cumulative rank to an item in the ID10 dimension.
 

Rank A metric

Step 3: Define the Multiplier Matrix

Next, define a multiplier matrix that determines the loop behavior across ranks in reverse order:

IFDEFINED(AFBY: -> 'Rank A'], 1, PREVIOUS(ID10 ON ID10.'Reverse ID') + 1)
+FILTER: ISDEFINED(A)]

Explanation:

  • The formula initializes with 1 where the rank matches.

  • Then it uses the PREVIOUS function across ID10 in reverse order.

  • The filter ensures only defined values of A are considered.
     

    Multiplier Matrix metric

     

Step 4: Apply the Multiplier in the Final Metric

To apply the multiplier and finalize your logic, use the following formula in your B- formula metric:

(ApBY: 'Rank A'] * 'Multiplier Matrix')
tREMOVE: ID10]

Explanation:

  • The pBY: 'Rank A'] switches the values of A from the Yearto the ID10 dimension.

  • This allows proper alignment with the multiplier values.

  • Finally, iREMOVE: ID10] aggregates the result back to the Year dimension.
     

    Final result

     

Hope this helps!


Hi ​@Issam Moalla ,

 

Thanks for the help, I tried it and it works perfectly.👍

 

Thanks

Apurv


Reply