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
D'Mario LewisD'Mario Lewis 

Map of Maps

Im creating map of a map of allocations using a church number as my key. The issue with my code is when I use the map.get(key) function and enter a church number I returns the last element map and I cant understand why. 
private Map<String, Map<String, Decimal>> AboveMinistryShareAllocationMap(List<causeview__Gift_Detail__c> allocationlist){
     
        Map<String, Map<String, Decimal>> Level1Above = new Map<String, Map<String, Decimal>>();
        Map<String, Decimal> Level2Above = new Map<String, Decimal> ();
        
        String churchnumber = allocationlist.get(0).churchnumber;
        Decimal amount = 0;
       
        for(causeview__Gift_Detail__c allocation : allocationlist){
            String allChurch = allocation.churchnumber;
            String fundname  = allocation.fundnote;
            
            if(allChurch.equals(churchnumber)){
                amount += allocation.amount
		Level2Above.put(fundname, amount);
            }
            
            else {
                
                Level1Above.put(churchnumber, Level2Above);
                Level2Above.clear();  
                amount = allocation.causeview__Approved_Amount__c;
                Level2Above.put(fundname, amount); 
                churchnumber = allChurch;
            } 
        }
return Level1Above;
}