This is new blog on knowledge share, today just got chance to work with SQL queries; i was just exploring the dimension extract for one of our customer, i produce this sql query which show main account and financial dimensions associated with main account; i though it is worth to share with AX community also.
-- This script is designed to show the values in columns for better read
-- Deleting if tmp table already exists
End -- creating new Tmp table.
Begin CREATE TABLE #MainAccountDimensionTmp
-- selecting main accounts and all financial dimensions and storing into tmp table
Begin Insert into #MainAccountDimensionTmp (Name, DisplayValue, MainAccount)
MainAccountLegalEntity as MALE
join MAINACCOUNT on MAINACCOUNT.RECID = MALE.MAINACCOUNT
join DEFAULTDIMENSIONVIEW as ddv on MALE.DEFAULTDIMENSION = ddv.DEFAULTDIMENSION --where MAINACCOUNTid = 'test01'
-- reading again from tmp table in way that values are showin in column.
-- please add as many dimesions as you want, like i have added 4 dimensins below.
Case Name When 'Department' then DISPLAYVALUE ELSE '' END
) AS 'Department',
Case Name when 'ICP' then DisplayValue ELSE '' END
) AS 'ICP',
Case Name when 'MISC' then DisplayValue ELSE '' END
) AS 'MISC',
Case Name when 'Expense_Class' then DisplayValue ELSE '' END
) AS 'Expense Class'
#MainAccountDimensionTmp Group by MainAccount
--select * from DEFAULTDIMENSIONVIEW