Skip to main content

Data & Intelligence

PowerDesigner Tips – Column Ordering

In our standards XEM file (extended model definition), I’ve added column ordering functionality by categorizing each column and then ordering the categories.

Column groups are defined in a BaseColumn template.  We have:

 

PRIM,0,%Primary%
ROWMETA,3,%extIsRowDateMeta%
META,4,%extIsMetaColumn%
AKNONMETA,1,%AllKeys%
BASE,2,TRUE

 

Basically, the first value is the name of the group, the second is the rank of the group in the table, and the remainder is a template expression that can be evaluated in the column context as a boolean expression.  Each line is evaluated until a true is found.  So, if a column is %Primary%, the group is PRIM and will be placed first (rank 0) in the table.

Data Intelligence - The Future of Big Data
The Future of Big Data

With some guidance, you can craft a data platform that is right for your organization’s needs and gets the most return from your data capital.

Get the Guide

Note that I’ve added extended attributes as needed for non-trivial cases, such as whether or not a column is a meta-data column.  In our case this is based on the stereotype of the column’s domain.

There’s a catch-all at the end for all other columns that don’t meet any other criteria.

The function that evaluates all this is as follows:

 

Function %Get%(col)
   Dim ln
   For Each ln In Split(col.Model.FindMetaExtensionByName(col, cls_TemplateTargetItem, EXT("extColumnGroups")).Value, vbCrLf)
      If Len(Trim(ln)) > 0 Then
         Dim parts : parts = Split(ln,",")
         If UCase(col.EvaluateTextFor(parts(2),EXTNAME)) = "TRUE" Then
            %Get% = parts(0)
            Exit Function
         End If
      End If
   Next
   %Get% = "None"
End Function

 

Basically, split the template by line and then by column and evaluate each line in turn.  extColumnGroups is the name of the template from above, EXTNAME is the name of our XEM.  All this goes into the Get section of an extended attribute (here called extColGroupName).

Finding the rank is the same, just change the line to

%Get% = parts(1)

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Chris Grenz

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram