Skip to main content
Solved

Top Tips for modeling in Pigment - Performance Optimisation

  • March 5, 2024
  • 2 replies
  • 238 views

Thu Mai
Master Trendsetter
Forum|alt.badge.img+10

Hi Pigmenteers! 

When reading Top Tips for modeling in Pigment - Part 2: Performance Optimisation, there’s an idea as highlighted in the screenshot below: to avoid doing too much within one metric, there’s “a good guideline is that, if you have to copy and paste part of a formula more than once, it may be worth its own metric” - I don’t quite get it, can you help explain this idea to me? 

 

Best answer by Nathan

Hi Thu Mai,

 

copy paste here means that the same “formula” exists in two metrics as part of a larger one.

We advise for that in order to avoid Pigment recalculating the same thing in several metrics & being able to parallelize calculations.

 

example of too much recalculations:

Salary = Annual Salary /12 * prorata(month,Employee.Start, Employee.End)

Tax = Annaul Salary / 12 * TaxRate[by:Employee.Country] * prorata(month,Employee.Start, Employee.End)

 

You should rather do that:

FTE =  prorata(month,Employee.Start, Employee.End)

Salary = Annual Salary /12 * FTE

Tax = Salary *TaxRate[by:Employee.Country]

2 replies

Nathan
Employee
Forum|alt.badge.img+12
  • Employee
  • Answer
  • March 5, 2024

Hi Thu Mai,

 

copy paste here means that the same “formula” exists in two metrics as part of a larger one.

We advise for that in order to avoid Pigment recalculating the same thing in several metrics & being able to parallelize calculations.

 

example of too much recalculations:

Salary = Annual Salary /12 * prorata(month,Employee.Start, Employee.End)

Tax = Annaul Salary / 12 * TaxRate[by:Employee.Country] * prorata(month,Employee.Start, Employee.End)

 

You should rather do that:

FTE =  prorata(month,Employee.Start, Employee.End)

Salary = Annual Salary /12 * FTE

Tax = Salary *TaxRate[by:Employee.Country]


Thu Mai
Master Trendsetter
Forum|alt.badge.img+10
  • Author
  • Master Trendsetter
  • March 5, 2024

@Nathan oh I got it, your example is very clear, thank you so much!!