JavaScript Data Grid to show results from two columns depends on the grouping

Hello, I created the following table with the first 5 columns using DashAG. I want to create the 6th column named “Desired_ Results” but haven’t been able to successfully do that by defining a function in js, (very new to JS Data Grid). The logic for the column is that at the security level (lowest level), “Desired_ Results” should contain the the data in the “Position Liquidity” column, but for the account level it should be the aggregated results of the the “Position Liquidity” times “Allocation”, and at the household level it should contain the aggregated results of the two accounts level. Can someone please help mw with the JavaScript Data Grid function to create this please?

Thanks in advance!
Lili

Group Security Name Market Value Allocation Position Liquidity Desired_ Results
Household 238,880.84 199.95%
Account1 75,968.50 36.39%
Canadian Fixed Income Pool 75,968.50 18.2% 2 2
Account2 162,912.34 163.55%
Canadian Fixed Income Corporate Class 109,604.11 26.3% 2 2
US Equity Value Corporate Class (14,201.47) 3.4% 2 2
International Equity Value Corp Class (10,717.34) 2.6% 2 2
Canadian Equity Alpha Corp Class 51,264.04 12.3% 2 2
US Equity Small Cap Corporate Class 1,822.63 0.4% 2 2
Real Estate Investment Corporate Class (227.83) 0.1% 1 1
International Equity Growth Corp Class 2,775.85 0.7% 2 2
Global Fixed Income Corporate Class (32,538.12) 7.8% 2 2
US Equity Growth Corporate Class 2,582.42 0.6% 2 2
Canadian Equity Value Corporate Class 26,474.26 6.3% 2 2
Emerging Markets Equity Corporate Class 4,076.11 1.0% 2 2
Canadian Equity Small Cap Corp Class 18,188.33 4.4% 2 2
International Equity Alpha Corp Class 11,659.51 2.8% 2 2
Canadian Equity Growth Corporate Class 4,447.95 1.1% 2 2
Enhanced Income Corporate Class 19,324.52 4.6% 2 2
US Equity Alpha Corp Class (31,622.63) 7.6% 2 2