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)

Best way to filter based on specific Dimension value?

(0) ShareShare
ReportReport
Posted on by 1,200

Hello,

I am working on a requested feature for procurement in 2012. Essentially the purchasing agents want a view where they can filter purchase requisitions based on the presence of a line that has been distributed in whole or part to a selected company. We use the "ProfitCenter" financial dimension to represent the "company" and a purchase requisition line can be distributed to any number of companies.

From what I have found on forums, etc it appears the only approach to getting the value for a specific dimension involves looping individually through the segments for each hierarchy based on the segment count. I am currently assuming only one hierarchy in the case of requisition lines. Is that a correct assumption?

Because the segments are potentially dynamic I see no good way to account for that in a query but I wanted to see if there were approaches I had not thought of or an existing class that is not documented well. I know that I want the “ProfitCenter” dimension but  using a “LIKE” query  doesn’t seem the best approach. I am not familiar with the dimension architecture in 2012 but it doesn’t seem to lend itself well to queries. Is the best I can hope for to count on the ProfitCenter being the second part of the DimensionAttributeValueCombination.DisplayValue field and using a LIKE query to try to filter?

Right now I have the following:

Join     PurchReqLine.SourceDocumentLine       to SourceDocumentLine.RecId  (1 to 1)
Join     SourceDocumentLine.RecId                       to AccountingDistribution.SourceDocumentLine  (1 to many)
Join    AccountingDistributionLedgerDimension to  DimensionAttributeValueCombination.RecId (1 to 1)
            WHERE DimensionAttributeValueCombination.DisplayValue is LIKE"*-XXX*" where XXX is the value selected by the user to filter to

Any better ideas out there? What am I missing? I am still not familiar with the Dimension architecture in 2012 to be honest and I am having a difficult time finding technical documentation on it. Any help or advice would be greatly appreciated :)

 

 

Thanks!

AnnaP

*This post is locked for comments

I have the same question (0)
  • Scott Cap Profile Picture
    on at

    Hi Anna,

    The structure of Dimensions has changed significantly in 2012. There are several helper classes which can be used to make lookups much easier. Here is some code retrieving the Cost Center from a sales order

    private str getCostCenter()
    {

        if(DimensionAttributeValueSetStorage::find(SalesTable::find(custInvoiceTrans.SalesId).DefaultDimension).elements() == 1)
        {
            return  DimensionAttributeValueSetStorage::find(SalesTable::find(custInvoiceTrans.SalesId).DefaultDimension).getDisplayValueByIndex(1);
        }
        else
        {
            return 'None';
        }
    }

     

    Here is some sample code to retrieve a dimension from a customer and display it.

    static void ShowDimension(Args _args)
    {
        CustTable                         custTable = CustTable::find("1101");
        DimensionAttributeValueSetStorage dimStorage;
        Counter i;
         
        dimStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);
     
        for (i=1 ; i<= dimStorage.elements() ; i++)
        {
            info(strFmt("%1 = %2", DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name,       
                                   dimStorage.getDisplayValueByIndex(i)));
        }
    }   

    The dimensions are stored much like a map object where each value has a coordinate. There are methods in the helper classes to locate both the value and its coordinate.

    Hope this helps,
    Scott
      

  • A Petersen Profile Picture
    1,200 on at

    Yes thanks. I have done something similar already in a class I have called "DimensionSegmentParser" for now. The trouble is I can't use that approach in a query. I would have to build up a RecordSet and use that in the Form I suppose. It just seems cumbersome as opposed to just being able to use a query or datasource ranges to filter to what I want.

    Does that make sense?

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