Exemplo n.º 1
0
        public void PivotFieldIsNotHierarchy()
        {
            string pivotFieldValue = "[TranDate].[Tran_YearMonthDay].[Tran_MonthAbbrev]";
            bool   isHierarchy     = DaxFilterCreator.PivotFieldIsHierarchy(pivotFieldValue);

            Assert.IsTrue(isHierarchy);
        }
Exemplo n.º 2
0
        public void ParseMdxWithHierarchy()
        {
            string pivotFieldNamesString = @"[Measures].[Trades CCA Sum]
[TranDate].[Tran_Year].[Tran_Year]
[TranDate].[Tran_YearMonthDay].[Tran_Year]
[TranDate].[Tran_YearMonthDay].[Tran_MonthAbbrev]
[TranDate].[Tran_YearMonthDay].[Tran_DayOfMonth]
[CounterCcy].[Counter Ccy].[Counter Ccy]
[TranDate].[Tran_MonthAbbrev].[Tran_MonthAbbrev]";

            string[] pivotFieldNames = pivotFieldNamesString.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            string   pivotItemValue  = "[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Jul]";

            var creator   = new DaxFilterCreator(pivotItemValue, pivotFieldNames);
            var daxFilter = creator.CreateDaxFilter();

            Assert.AreEqual("Tran_Year", daxFilter.ColumnNameHierarchy[0].ColumnName);
            Assert.AreEqual("Tran_MonthAbbrev", daxFilter.ColumnNameHierarchy[1].ColumnName);
            Assert.AreEqual("2.014E3", daxFilter.ValueHierarchy[0]);
            Assert.AreEqual("Jul", daxFilter.ValueHierarchy[1]);
        }
Exemplo n.º 3
0
        private static void AddSinglePageFieldFiltersToDic(Excel.PivotFields pfs, PivotCellDictionary pivotCellDic)
        {
            //Filter by page field if not all items are selected
            foreach (Excel.PivotField pf in pfs)
            {
                var dicCell = pivotCellDic.SingleSelectDictionary;

                if (DaxFilterCreator.PivotFieldIsHierarchy(pf.SourceName))
                {
                    continue;
                }

                string pageName = pf.DataRange.Value2;
                if (pageName == "All" || pageName == "(Multiple Items)")
                {
                    continue;
                }

                var cubeField = pf.CubeField;
                dicCell.Add(pf.Name, cubeField.Name + ".&[" + pageName + "]");
            }
        }