My target now is to convert the above table to a view that stores all accounts in YTD basis. This means that only the PL account code which is 600000x series need to be calculated to YTD values. The desired output is below:

What does this condition means?---CASE WHEN t.Account -5000000 < 1000000 ---

Actually, from my fact table, it has a column called 'acc_type' which stores the values (asset, equity, liability, income, expense).The 6000000x series accounts is the 'income' and 'expense' acc_type value.I would think that it would be more of a better way if the calculation of YTD values is based on acc_type attribute?

you've lot of other conditions also added which i dont even have an idea of and you've never specified them so far alsoso post the data for all those fields and tell what output you want out of them and i can help.