HierarchySubsetElementDelete odd behavior
Posted: Fri Oct 26, 2018 6:45 pm
Have the following subset with hundreds of elements:
This code fails with "Unable to delete element at position "0" from dimension:subset":
However do this (note the two extra lines after HierarchySubsetMDXSet) and it works like a charm:
Is it just me or does it seem there is a lot of quirkiness with the Hierarchy functions? I'not saying I'd be fine with it, but if the documentation said "HEY! Run these two seemingly unrelated functions before executing HierarchySubsetElementDelete!" I would at least think it was planned that way, kind of like certain datasource functions go together. But without that, this is just nuts and time consuming the figure out the right combination of functions to run to get some functions to work. See my post on MDX subsets and assigning a caption to a hierarchy for another example.
All Accounts
100-100-100
200-100-101
...
This code fails with "Unable to delete element at position "0" from dimension:subset":
Code: Select all
sMDX = EXPAND('UNION({[%dimAccountsMaster%].[%hierAccountsForecast%].currentmember}, TM1FILTERBYLEVEL(TM1SUBSETALL([%dimAccountsMaster%].[%hierAccountsForecast%]), 0), ALL)');
HierarchySubsetCreate(dimAccountsMaster, hierAccountsForecast, subAccountsForecast);
HierarchySubsetMDXSet(dimAccountsMaster, hierAccountsForecast, subAccountsForecast, sMDX);
HierarchySubsetElementDelete(dimAccountsMaster, hierAccountsForecast, subAccountsForecast, 1);
Code: Select all
sMDX = EXPAND('UNION({[%dimAccountsMaster%].[%hierAccountsForecast%].currentmember}, TM1FILTERBYLEVEL(TM1SUBSETALL([%dimAccountsMaster%].[%hierAccountsForecast%]), 0), ALL)');
HierarchySubsetCreate(dimAccountsMaster, hierAccountsForecast, subAccountsForecast);
HierarchySubsetMDXSet(dimAccountsMaster, hierAccountsForecast, subAccountsForecast, sMDX);
sFirstElement = HierarchySubsetGetElementName(dimAccountsMaster, hierAccountsForecast, subAccountsForecast, 1);
nFirstElementIndex = HierarchySubsetElementGetIndex(dimAccountsMaster, hierAccountsForecast, subAccountsForecast, sFirstElement, 1);
HierarchySubsetElementDelete(dimAccountsMaster, hierAccountsForecast, subAccountsForecast, 1);