共用方式為


HOWTO: Dynamic rows or columns with a dimension property filter

To filter rows and columns by a filter selection has previously been discussed here. But one thing you might not have noticed is that the list of property values (aka the filter scope) is static. If a new member property appears the form needs to be modified to include it, even if the “all” button. This is different than a normal filter, where the UI allows a dynamic filter scope by a number of expressions. Luckily in the RDL both kinds of filters are stored in the same fashion. The only thing that makes a dimension property filter (DPF) different is that the hierarchy defined for the scope query is the attribute hierarchy that is also created on the AS cube. So in the report definition itself the scope can be modified from a static set to a dynamic set by looking at the RDL for a regular filter and deriving the kinds of expressions supported.

Warning, this involves going to the RDL tab of the report properties editor and editing the extensions that the PPS Planning AddIn uses. I’ll readily admit that this not always a trivial task. It takes some practice to map from the regular treeview tab to the RDL tab. Going into that level of detail is a topic for another post. So for now I’m going to assume that you’ve done some experimentation and know what you’re looking for. (As a hint, while experimenting in your-land use a simple matrix and only 1 filter at a time, it cuts down dramatically on all the extra XML you have to wade through.)

So then, here’s an example of just the HierarchyMemberSets for a normal filter with “Entity.CorpMgmtEnt.All” and “Entity.CorpMgmtEnt.All (children of)” selected as the scope:

    1: <HierarchyMemberSets>
    2:   <Hierarchy>[Entity].[CorpMgmtEnt]</Hierarchy>
    3:   <MemberSets>
    4:     <MemberSet>
    5:       <Member>
    6:         <Label>ASH</Label>
    7:         <UniqueName>[Entity].[CorpMgmtEnt].&amp;[5018]</UniqueName>
    8:       </Member>
    9:       <Selection>Members</Selection>
   10:     </MemberSet>
   11:     <MemberSet>
   12:       <Member>
   13:         <Label>ASH</Label>
   14:         <UniqueName>[Entity].[CorpMgmtEnt].&amp;[5018]</UniqueName>
   15:       </Member>
   16:       <Selection>Children</Selection>
   17:     </MemberSet>
   18:   </MemberSets>
   19: </HierarchyMemberSets>

The key is for a single static selection you’ll see “<Selection>Members</Selection>” and for a dynamic selection you’ll see “<Selection>Children</Selection>” where the type of selection varies. Once you figure out the kind of selection you want by looking at normal filters we can go look at what a property filter look like. So to start with I’ll remove the Entity filter and use a Currency filter based on the property name. Here’s the HierarchyMemberSets for that:

    1: <HierarchyMemberSets>
    2:   <Hierarchy>[Currency].[MemberName]</Hierarchy>
    3:   <MemberSets>
    4:     <MemberSet>
    5:       <Member>
    6:         <Label>Canadian Dollar</Label>
    7:         <UniqueName>Canadian Dollar</UniqueName>
    8:       </Member>
    9:       <Selection>Members</Selection>
   10:     </MemberSet>
   11:     <MemberSet>
   12:       <Member>
   13:         <Label>EURO</Label>
   14:         <UniqueName>EURO</UniqueName>
   15:       </Member>
   16:       <Selection>Members</Selection>
   17:     </MemberSet>
   18:     <MemberSet>
   19:       <Member>
   20:         <Label>US Dollar</Label>
   21:         <UniqueName>US Dollar</UniqueName>
   22:       </Member>
   23:       <Selection>Members</Selection>
   24:     </MemberSet>
   25:     <MemberSet>
   26:       <Member>
   27:         <Label>Yen</Label>
   28:         <UniqueName>Yen</UniqueName>
   29:       </Member>
   30:       <Selection>Members</Selection>
   31:     </MemberSet>
   32:   </MemberSets>
   33:   <MemberProperties>
   34:     <MemberProperty>MemberName</MemberProperty>
   35:   </MemberProperties>
   36: </HierarchyMemberSets>

So now we can see why the selection is static: They are all listed separately (just ignore the fact that the uniquename is not really a uniquename, that artifact is a topic for another post). You’ll note that the hierarchy though is using the attribute hierarchy created by AS so you might have even guessed that the AddIn might generate MDX supporting expressions for DPFs. In fact, I had forgotten about this until somebody posted in the forums a month or so ago that they wanted this scope to be dynamic.

Anyway, in my example I want all the currencies to be available no matter what changes are made to the dimension. So I’m going to change the scope to be the MDX expression “[Currency].[MemberName].[All].[Children]”. First I remove all the static member sets and insert a proper uniquename:

    1: <HierarchyMemberSets>
    2:   <Hierarchy>[Currency].[MemberName]</Hierarchy>
    3:   <MemberSets>
    4:     <MemberSet>
    5:       <Member>
    6:         <Label>All</Label>
    7:         <UniqueName>[Currency].[MemberName].[All]</UniqueName>
    8:       </Member>
    9:       <Selection>Children</Selection>
   10:     </MemberSet>
   11:   </MemberSets>
   12:   <MemberProperties>
   13:     <MemberProperty>MemberName</MemberProperty>
   14:   </MemberProperties>
   15: </HierarchyMemberSets>

Then click Validate RDL to make sure there are no syntax errors. Then click ok and the report will be refreshed. Now using the filter should give the same values as the static selection, but when a new currency member is added with a new value for the property MemberName it will automatically appear in this list. Voila! Not so simple, but not so hard.

 

Playing in the land of Peter Eb. while writing this post...Pigs in Zen by Jane's Addiction from Jane's Addiction