web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Query for Cost Center Active From & To Dates in AX2012 R3

(0) ShareShare
ReportReport
Posted on by

Hello, I'm trying to get a list of all cost center values along with their active from and two dates using the view dbo.DIMATTRIBUTEOMCOSTCENTER as the main source which returns all cost center codes and descriptions. The problem is that when I join the view to DIMENSIONATTRIBUTEVALUE and then DIMENSIONATTRIBUTE to get the dates I'm only getting a subset.

So for example this query returns 3 records:

SELECT *
FROM dbo.DIMATTRIBUTEOMCOSTCENTER dacc
WHERE 1 = 1
AND dacc.VALUE IN ('AAAA', 'BBBB', 'CCCC')

But when I do a LEFT JOIN to get the active from and two dates I only get back two records, one for 'AAAA' and 'BBBB'. 'CCCC' is not returned.

SELECT
 dacc.RECID
, dacc.VALUE
, dacc.NAME
, dav.ACTIVEFROM
, dav.ACTIVETO
, da.NAME AS DimensionAttribute_NAME

FROM dbo.DIMATTRIBUTEOMCOSTCENTER dacc
LEFT OUTER JOIN dbo.DIMENSIONATTRIBUTEVALUE dav ON dacc.RECID = dav.ENTITYINSTANCE
LEFT OUTER JOIN dbo.DIMENSIONATTRIBUTE da ON dav.DIMENSIONATTRIBUTE = da.RECID

WHERE 1 = 1
AND dacc.VALUE IN ('AAAA', 'BBBB', 'CCCC')
AND da.NAME = 'CostCenter'

Anyone have any ideas? Also I don't have to use this query if there's a better way to do this.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi RMacCan!

    Try to remove AND da.NAME = 'CostCenter'. I think you don't need it because of you already using dbo.DIMATTRIBUTEOMCOSTCENTER.

  • Community Member Profile Picture
    on at

    Thanks for the response. I did try removing the filter that but then I was getting back too many rows. DIMENSIONATTRIBUTEVALUE has potentially multiple records per ENTITYINSTANCE value. For example, the ENTITYINSTANCE value for cost center 'AAAA' also returns a row for 'Project' from DIMENSIONATTRIBUTEVALUE with different active from and to dates. I need the 'CostCenter' filter to limit the results.

  • Rustem Galiamov Profile Picture
    8,072 on at

    Ahh..yes. Sorry. In my case a have only CostCenter in dbo.DIMATTRIBUTEOMCOSTCENTER. Are you sure that related records are exists in joined tables ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans