Example #1
0
        public static List <DaxFilter> ConvertPivotCellMdxToDaxFilterList(string mdxString)
        {
            mdxString = mdxString.Trim();
            mdxString = mdxString.Substring(1, mdxString.Length - 2);
            string[] itemStringArray = mdxString.Split(',');
            for (int i = 0; i < itemStringArray.Length; i++)
            {
                itemStringArray[i] = itemStringArray[i].Trim();
            }

            itemStringArray = itemStringArray.Where(x =>
            {
                // exclude the measure as it's not a DAX filter
                if (x.Substring(0, 10) == "[Measures]")
                {
                    return(false);
                }
                return(true);
            }).ToArray();

            var result = new List <DaxFilter>();

            foreach (string itemString in itemStringArray)
            {
                var daxFilter = DaxDrillParser.CreateDaxFilterFromHierarchy(itemString, null);
                result.Add(daxFilter);
            }

            return(result);
        }
Example #2
0
        public static List <DaxFilter> ConvertPivotTableMdxToDaxFilterList(string mdxString, IEnumerable <string> pivotFieldNames)
        {
            var mdxParser = new TableMdxParser(mdxString);

            string[] columnStringArray = mdxParser.ConvertColumnMdxToArray();

            string[] rowStringArray = mdxParser.ConvertRowMdxToArray();

            var result = new List <DaxFilter>();

            foreach (string itemString in columnStringArray)
            {
                var daxFilter = DaxDrillParser.CreateDaxFilterFromHierarchy(itemString.Trim(), pivotFieldNames);
                result.Add(daxFilter);
            }
            foreach (string itemString in rowStringArray)
            {
                var daxFilter = DaxDrillParser.CreateDaxFilterFromHierarchy(itemString.Trim(), pivotFieldNames);
                result.Add(daxFilter);
            }

            return(result);
        }