I have the following script. While I included all of it the only thing I really want to accomplish is write this script once and loop through it for every month from JAN2010 through OCT2013. I have noted the variables (in red) and the table name I have created but would need to change each time I loop through. Currently I create this same script 40+ times to get it for each month through 2013!!
For instance on the second loop though JAN2010WHERE would become FEB2010WHERE, JAN2010RETENSION would become FEB2010RENTENSION, and the table name Line_of_BusinessCube_Jan2010 would become Line_of_Business_Feb2010 and so on for each successive month.
ProductionByLine_of_BusinessByCust:LoadLine_of_Businessas[Line_of_Business Cube Pre],sum([Commission]) as[Commission Line_of_Business Cube Pre]Resident Production Where $(JAN2010WHERE) GroupBy[Line_of_Business] OrderbyLine_of_BusinessASC; leftJoin(ProductionByLine_of_BusinessByCust)LoadLine_of_Businessas[Line_of_Business Cube Pre],Customer_Nameas[Cust Cube Pre],FirstValue(ID|Customer) AsID|Customer,sum([Commission]) as[Commission Line_of_BusinessCust Cube Pre]Resident Production Where $(JAN2010WHERE)GroupBy[Line_of_Business],Customer_NameOrderByLine_of_BusinessASC;