function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jameskCAjameskCA 

Help with nested collections

I'm very new to apex and I'm looking for some advice on how to accomplish the following:

We have 12 "production" formula fields, one for each month.  Here is an example:
IF(ISPICKVAL( Tilt__c ,'10'), 106.17 * System_kW_n__c * Azimuth_Multiplier__c * Inverter_Performance_Factor__c * Solar_Access_Estimate__c , 
IF(ISPICKVAL( Tilt__c ,'20'), 118.27 * System_kW_n__c * Azimuth_Multiplier__c * Inverter_Performance_Factor__c * Solar_Access_Estimate__c , 
IF(ISPICKVAL( Tilt__c ,'30'), 127.59 * System_kW_n__c * Azimuth_Multiplier__c * Inverter_Performance_Factor__c * Solar_Access_Estimate__c ,0)))

I'm trying to create a method that will be a little more elegant than just hard coding all of it with if statements.  I'd like to have a method that is passed all of the above as parameters (e.g. Tilt__c, System_kW_n__c etc...) and based on the tilt value return a collection (list?) with each month (0-12) with the appropriate multiplier value (the 106.17, 118.27, 127.59 from above as an example).

Sorry if the explanation is confusing, again this is new to me.

I'm open to any suggestions, but I was thinking it could be accomplished with nested Lists?  Each month would need to be accessible via 0-12 as the index.  Then within each index I would need to have 3 more keys (10, 20, 30 which is the tilt value) and each of these keys would correspond to a value which is what I actually need to return for each month.  

Any help would be greatly appreciated.