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
Marcelo AgostinhoMarcelo Agostinho 

Creating Table with Apex...

01/2010 - Customer 1Customer 1Hello... sorry but i dont know if this is the best Board to post my question.

 

Well... actually i need to create a table getting datas from a map...

 

 

private List<MovimentoMes__c> movimentosClientes = [Select m.Vendedor__r.Name, m.Cliente__r.cliente__c, m.Cliente__r.campoLivreAlt__c ,											 m.Cliente__r.municipio__c , m.Cliente__r.uf__c ,m.Mes_de_Referencia__c, m.Valor__c									    From MovimentoMes__c m];
	
	public void mapClienteValorMeses(){
		
		clienteFaturamentoMes = new Map<String,Map<String,Double>>();
	
		for(MovimentoMes__c movimento: movimentosClientes){
			
			cliente = movimento.Cliente__r.cliente__c;
			mesDeReferencia = movimento.Mes_de_Referencia__c;
			valorMesReferencia = movimento.Valor__c;
			
			if(clienteFaturamentoMes.containsKey(cliente)){
				
				faturamentoMes = clienteFaturamentoMes.get(cliente);
				
				if(faturamentoMes.containsKey(mesDeReferencia)){
					totalMes = faturamentoMes.get(mesDeReferencia);
					totalMes += valorMesReferencia;
					faturamentoMes.put(mesDeReferencia,totalMes);
				}else{					
					faturamentoMes.put(mesDeReferencia,valorMesReferencia);					
				}
		
			
			} else {
				
				faturamentoMes = new Map<String,Double>();
				faturamentoMes.put(mesDeReferencia,valorMesReferencia);	
				
				clienteFaturamentoMes.put(cliente,faturamentoMes);
			}
		}
		
	}

Explaining the code above.

My external map receive a customer (String) as Key, and an Map(String,Double) as Value, and the Internal Map Receive a Month of Purchase(String) as Key and a Value of Purchase(Double) as Value.

 

So where is my problem....

 

Considering 12 month (Not exactly all months of the same year)... some customers bought something on month 01, 02, 03, and another bought something on month, 04,06,08...

 

I know exactly the12 month period, where it begin and where it end...

 

What i need to do is something like it:

 

A table where the first column is the name of the customer...the first row is the header with all the month period... 

But i said before some customers doesnt buy all months... and this data will not exist at Map... so if one customer doesnt buy one month... at table this need to appear with 0, how i can do it?

 

Well sorry about my english =)

 

Very thanks for everything!


DharmeshDharmesh

You can create List of List of twelve items where data doenst exist for customer for particular month you can put 0 or null in that cell (position on List)