Hello Pigment Community,
I am trying to calculate the quarterly bonus of my employees and shift it by one month to simulate the payout on the first month after the quarter end.
I will detail below the steps of my calculation and where I am stuck:
- My bonus expenses are by month. I was able to sum the quarterly amount with a [BY SUM: Month.Quarter] modifier.
- I want to add again the “Month” dimension and put this quarterly amount on the last month of the quarter only (or first month of the quarter, it doesn’t matter). This is where I am stuck. If I use a [BY CONSTANT: Month.Quarter] - the amount is written on all months of the quarter, and then I am unable to filter only on the first or last month of the quarter.
- The last step will be to SHIFT this amount by 1 month to simulate the payout on the first month after the quarter ends.
I would appreciate your help if you already worked on this topic!
Thanks in advance,
Best answer by francoisView original
Here’s what I came up with, which might not be the clearest solution, but it works.
I’ve followed your steps and decided to filter on months by using this formula (basically comparing whether each Months’ quarter is different from the next, which is only true for the last month on each quarter.
I then incorporated this calculation in a filter directly and got this formula.
If you feel daring, this approach is a bit more complex but also more optimized:
Instead of allocating on all months in the quarters, I’ve filtered the Months (using the same rule as above) directly in the allocation key
Month.Quarter. This way Pigment only allocates data on the relevant Months.
The formula is a bit less legible though. There’s probably other / cleaner ways to do it, if you think of another solution let me know!
Thank you François for the very quick answer, it’s working very well!
Thank you François, do you know which solution is the best in terms of performance?
These should all be equivalent in speed.
Out of the three the second one could be more optimized (slightly smaller cardinality because we don’t allocate on all months), but unless you have millions of employees receiving bonus they should all behave the same as it’s clearly not a complex / exceptionally large calculation.
Thanks, very useful!
This helped me a lot today! Thank you!!