function for week, asc desc calc