Following query taking lots of time to execute. I am executing this in SSRS. I tried my level best to optimize it. Can this be optimized more

if @PeriodSelected is null and @ExpenseType='Non Chargeable'beginSELECT EC.EXPENSE_DESC,SUP.SUPPLIER_DESC,SUM((NL.BASEVAL)*CASE WHEN CURR.RATE IS NULL THEN 1 ELSE CURR.RATE END) TOTALCLAIMFROMVW_FACT_NLTRANS NLINNER JOINVW_DIM_EXPENSECODE ECON NL.EXPENSE_SK=EC.EXPENSE_SK AND NL.COMPANY_SK=EC.COMPANY_SKINNER JOIN VW_DIM_SUPPLIER SUP ON NL.SOURCEACC=SUP.SUPPLIERID AND NL.COMPANY_SK=SUP.COMPANY_SKLEFT OUTER JOIN VW_FACT_CURRENCY CURRON NL.COMPANY_SK=CURR.COMPANY_SK AND CURR.CURRENCY IN ('STER','GBP')WHERE NL.PERIODID<=@PeriodEnd AND NL.PERIODID>=@PeriodStartAND (EC.EXPENSEGROUP NOT IN ('2-###-##') AND EC.EXPENSECODE NOT IN ('8-010-02','8-010-01'))AND NL.COMPANY_SK IN (@Company)AND NL.[DOC-ID] IN ('EXIN','EXCN') AND SUP.LEDGER='EX'GROUP BY EC.EXPENSE_DESC,SUP.SUPPLIER_DESCORDER BY SUM((NL.BASEVAL)*CASE WHEN CURR.RATE IS NULL THEN 1 ELSE CURR.RATE END) DESCendif @PeriodSelected is not null and @ExpenseType='Non Chargeable'beginSELECT EC.EXPENSE_DESC,SUP.SUPPLIER_DESC,SUM((NL.BASEVAL)*CASE WHEN CURR.RATE IS NULL THEN 1 ELSE CURR.RATE END) TOTALCLAIMFROMVW_FACT_NLTRANS NLINNER JOINVW_DIM_EXPENSECODE ECON NL.EXPENSE_SK=EC.EXPENSE_SK AND NL.COMPANY_SK=EC.COMPANY_SKINNER JOIN VW_DIM_SUPPLIER SUP ON NL.SOURCEACC=SUP.SUPPLIERID AND NL.COMPANY_SK=SUP.COMPANY_SKLEFT OUTER JOIN VW_FACT_CURRENCY CURRON NL.COMPANY_SK=CURR.COMPANY_SK AND CURR.CURRENCY IN ('STER','GBP')WHERE NL.PERIODID=@PeriodSelected AND (EC.EXPENSEGROUP NOT IN ('2-###-##') AND EC.EXPENSECODE NOT IN ('8-010-02','8-010-01'))AND NL.COMPANY_SK IN (@Company)AND NL.[DOC-ID] IN ('EXIN','EXCN') AND SUP.LEDGER='EX'GROUP BY EC.EXPENSE_DESC,SUP.SUPPLIER_DESCORDER BY SUM((NL.BASEVAL)*CASE WHEN CURR.RATE IS NULL THEN 1 ELSE CURR.RATE END) DESCend

if @PeriodSelected is null and @ExpenseType='Chargeable'beginSELECT EC.EXPENSE_DESC,SUP.SUPPLIER_DESC,SUM((NL.BASEVAL)*CASE WHEN CURR.RATE IS NULL THEN 1 ELSE CURR.RATE END) TOTALCLAIMFROMVW_FACT_NLTRANS NLINNER JOINVW_DIM_EXPENSECODE ECON NL.EXPENSE_SK=EC.EXPENSE_SK AND NL.COMPANY_SK=EC.COMPANY_SKINNER JOIN VW_DIM_SUPPLIER SUP ON NL.SOURCEACC=SUP.SUPPLIERID AND NL.COMPANY_SK=SUP.COMPANY_SKLEFT OUTER JOIN VW_FACT_CURRENCY CURRON NL.COMPANY_SK=CURR.COMPANY_SK AND CURR.CURRENCY IN ('STER','GBP')WHERE NL.PERIODID<=@PeriodEnd AND NL.PERIODID>=@PeriodStartAND (EC.EXPENSEGROUP IN ('2-###-##'))AND NL.COMPANY_SK IN (@Company)AND NL.[DOC-ID] IN ('EXIN','EXCN') AND SUP.LEDGER='EX'GROUP BY EC.EXPENSE_DESC,SUP.SUPPLIER_DESCORDER BY SUM((NL.BASEVAL)*CASE WHEN CURR.RATE IS NULL THEN 1 ELSE CURR.RATE END) DESCendif @PeriodSelected is not null and @ExpenseType='Chargeable'beginSELECT EC.EXPENSE_DESC,SUP.SUPPLIER_DESC,SUM((NL.BASEVAL)*CASE WHEN CURR.RATE IS NULL THEN 1 ELSE CURR.RATE END) TOTALCLAIMFROMVW_FACT_NLTRANS NLINNER JOINVW_DIM_EXPENSECODE ECON NL.EXPENSE_SK=EC.EXPENSE_SK AND NL.COMPANY_SK=EC.COMPANY_SKINNER JOIN VW_DIM_SUPPLIER SUP ON NL.SOURCEACC=SUP.SUPPLIERID AND NL.COMPANY_SK=SUP.COMPANY_SKLEFT OUTER JOIN VW_FACT_CURRENCY CURRON NL.COMPANY_SK=CURR.COMPANY_SK AND CURR.CURRENCY IN ('STER','GBP')WHERE NL.PERIODID=@PeriodSelected AND (EC.EXPENSEGROUP IN ('2-###-##'))AND NL.COMPANY_SK IN (@Company)AND NL.[DOC-ID] IN ('EXIN','EXCN') AND SUP.LEDGER='EX'GROUP BY EC.EXPENSE_DESC,SUP.SUPPLIER_DESCORDER BY SUM((NL.BASEVAL)*CASE WHEN CURR.RATE IS NULL THEN 1 ELSE CURR.RATE END) DESCend

What you have here is a stored proc with multiple execution paths. Read this article from Gail that explains this situation and a great way to deal with the sometime performance issues you are experiencing.