Custom Computation based on a filtered data point

I have a scenario where I need to do a computation based on a predetermined proportion as below

If company category = tenant

Allocated cost = total_amortized_cost + Direct cost % * total amortized cost (if Company = ‘ABC Corp’)

For example, For Emirates (in Dec’21), the allocated cost should be computed as $283.5K+17.1%*($619K) = $388.9K

I am able to get the allocated cost at an aggregate level but run into errors when I try to compute this for each of the fields under ‘Tenant’

What are your direct cost % and total amortized cost calculations?

Hi Max

Total Amortized cost, year_month and Company are not computed but part of the original data set. I will share the computation for direct cost as below -

Company Category = ifelse(isNull(Company),‘Null’,ifelse(Company<>‘ABC Corp’,‘Customer’,‘Central’))
Direct cost = sumOver(sum({total_amortized_cost}),[{Company Category},{year_month}])
Direct Cost% = sumif({total_amortized_cost},{Company Category}=‘Customer’)/({Direct cost })