示例#1
0
        public void ConvertPivotTableMdxToDaxFilterList()
        {
            var mdxString = @"SELECT NON EMPTY Hierarchize({[TranDate].[Tran_Year].[Tran_Year].AllMembers}) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS  FROM (SELECT ({[TranDate].[Tran_Year].&[2.016E3], [TranDate].[Tran_Year].&[2.015E3]}) ON COLUMNS  FROM (SELECT ({[CounterCcy].[Counter Ccy].&[EUR],[CounterCcy].[Counter Ccy].&[USD]}) ON COLUMNS  FROM [Model])) WHERE ([Account].[Account Currency].[All],[Activity].[Activity L1].[All],[CounterCcy].[Currency L1].&[Major],[Activity].[Is Hedgeable].&[True],[CounterCcy].[Counter Ccy Is Func].&[False],[SnapshotReported].[Compare Name].&[Current],[Snapshot].[Snapshot].&[Current],[Measures].[Trades CCA Sum]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS";

            var daxFilterList = DaxDrillParser.ConvertPivotTableMdxToDaxFilterList(mdxString, null);

            #region User Friendly Result
            foreach (var df in daxFilterList)
            {
                Console.WriteLine("Column = {0}; Value = {1};", df.ColumnName, df.Value);
            }
            #endregion

            #region Assert
            IEnumerable <DaxFilter> columnDfs = null;
            IEnumerable <DaxFilter> valueDfs  = null;

            columnDfs = daxFilterList.Where(c => c.ColumnName == "Tran_Year");
            Assert.AreEqual(2, columnDfs.Count());

            valueDfs = columnDfs.Where(c => c.Value == "2.016E3");
            Assert.AreEqual(1, valueDfs.Count());

            valueDfs = columnDfs.Where(c => c.Value == "2.015E3");
            Assert.AreEqual(1, valueDfs.Count());

            columnDfs = daxFilterList.Where(c => c.ColumnName == "Counter Ccy");
            Assert.AreEqual(2, columnDfs.Count());

            #endregion
        }
示例#2
0
        public void ParseAll()
        {
            #region Arrange

            var singDic = new Dictionary <string, string>();
            singDic.Add("[Usage].[Inbound or Outbound].[Inbound or Outbound]",
                        "[Usage].[Inbound or Outbound].&[Inbound]");
            singDic.Add("[Usage].[Call Type].[Call Type]",
                        "[Usage].[Call Type].&[MOC]");
            singDic.Add("[UsageDate].[Usage_Year].[Usage_Year]",
                        "[UsageDate].[Usage_Year].&[2014]");
            singDic.Add("[UsageDate].[Usage_MonthAbbrev].[Usage_MonthAbbrev]",
                        "[UsageDate].[Usage_MonthAbbrev].&[May]");
            #endregion

            #region Parse
            string commandText;

            var pivotCellDic = new PivotCellDictionary();
            pivotCellDic.SingleSelectDictionary = singDic;

            using (var tabular = new DaxDrill.Tabular.TabularHelper(serverName, "Roaming"))
            {
                tabular.Connect();
                commandText = DaxDrillParser.BuildQueryText(tabular, pivotCellDic, "Gross Billed Sum", 99999);
                tabular.Disconnect();
            }
            #endregion

            #region Assert
            Console.WriteLine(commandText);

            #endregion
        }
示例#3
0
        public void ParseCellDictionary()
        {
            #region Arrange

            var excelDic = new Dictionary <string, string>();
            excelDic.Add("[Usage].[Inbound or Outbound].[Inbound or Outbound]",
                         "[Usage].[Inbound or Outbound].&[Inbound]");
            excelDic.Add("[Usage].[Call Type].[Call Type]",
                         "[Usage].[Call Type].&[MOC]");
            excelDic.Add("[UsageDate].[Usage_Year].[Usage_Year]",
                         "[UsageDate].[Usage_Year].&[2014]");
            excelDic.Add("[UsageDate].[Usage_MonthAbbrev].[Usage_MonthAbbrev]",
                         "[UsageDate].[Usage_MonthAbbrev].&[May]");
            #endregion

            #region Parse
            var pivotCellDic = new PivotCellDictionary();
            pivotCellDic.SingleSelectDictionary = excelDic;
            string commandText;
            using (var tabular = new DaxDrill.Tabular.TabularHelper(serverName, "Roaming"))
            {
                tabular.Connect();
                commandText = DaxDrillParser.BuildFilterCommandText(pivotCellDic, tabular, null);
                tabular.Disconnect();
            }
            #endregion

            #region Assert
            Console.WriteLine(commandText);

            #endregion
        }
示例#4
0
        public static void AddMultiplePageFieldFilterToDic(IEnumerable <string> pivotFieldNames, string ptMdx,
                                                           PivotCellDictionary pivotCellDic)
        {
            var daxFilterList = DaxDrillParser.ConvertPivotTableMdxToDaxFilterList(ptMdx, pivotFieldNames);

            DaxDrillParser.ConvertDaxFilterListToDictionary(daxFilterList, pivotCellDic.MultiSelectDictionary);
        }
示例#5
0
        public static string GetMeasureName(Excel.Range rngCell)
        {
            Excel.PivotItem pi = null;
            pi = rngCell.PivotItem;
            string piName = pi.Name;

            return(DaxDrillParser.GetMeasureFromPivotItem(piName));
        }
示例#6
0
 public static void SetPivotFieldPage(Excel.PivotField pf, string currentPageName)
 {
     pf.ClearAllFilters();
     if (currentPageName != "All")
     {
         var pageName = DaxDrillParser.CreatePivotFieldPageName(pf.Name, currentPageName);
         pf.CurrentPageName = pageName;
     }
 }
示例#7
0
        public void ParsePivotItemValue()
        {
            var itemString = "[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Jul]";
            var daxFilter  = DaxDrillParser.CreateDaxFilterFromHierarchy(itemString, null);

            Assert.AreEqual(true, daxFilter.IsHierarchy);
            Assert.AreEqual("Tran_YearMonthDay", daxFilter.ColumnName);
            Assert.AreEqual("TranDate", daxFilter.TableName);
            Assert.AreEqual("2.014E3", daxFilter.ValueHierarchy[0]);
            Assert.AreEqual("Jul", daxFilter.ValueHierarchy[1]);
        }
示例#8
0
        public void ParsePivotText()
        {
            #region Parse
            var columnCommandText = DaxDrillParser.GetColumnFromPivotField("[Usage].[Inbound or Outbound].[Inbound or Outbound]");
            Assert.AreEqual("Inbound or Outbound", columnCommandText);

            var tableCommandText = DaxDrillParser.GetTableFromPivotField("[Usage].[Inbound or Outbound].[Inbound or Outbound]");
            Assert.AreEqual("Usage", tableCommandText);

            var pivotItemCommandText1 = DaxDrillParser.GetValueFromPivotItem("[Usage].[Inbound or Outbound].&[Inbound]");
            Assert.AreEqual("Inbound", pivotItemCommandText1);

            var pivotItemCommandText2 = DaxDrillParser.GetValueFromPivotItem("[Usage].[Inbound or Outbound].[Inbound]");
            Assert.AreEqual("Inbound", pivotItemCommandText2);

            #endregion
        }
示例#9
0
        public void ParseHierTableMdx()
        {
            string mdxString  = @"SELECT NON EMPTY Hierarchize(DrilldownMember(CrossJoin({[TranDate].[Tran_Year].[All],[TranDate].[Tran_Year].[Tran_Year].AllMembers}, {([TranDate].[Tran_MonthAbbrev].[All])}), [TranDate].[Tran_Year].[Tran_Year].AllMembers, [TranDate].[Tran_MonthAbbrev])) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY Hierarchize({DrilldownLevel({[CounterCcy].[Counter Ccy].[All]},,,INCLUDE_CALC_MEMBERS)}) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON ROWS  FROM (SELECT ({[TranDate].[Tran_Year].&[2.016E3]},{[TranDate].[Tran_MonthAbbrev].&[Jun], [TranDate].[Tran_MonthAbbrev].&[May], [TranDate].[Tran_MonthAbbrev].&[Apr], [TranDate].[Tran_MonthAbbrev].&[Mar], [TranDate].[Tran_MonthAbbrev].&[Feb], [TranDate].[Tran_MonthAbbrev].&[Jan]}) ON COLUMNS  FROM (SELECT ({[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Jul],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Mar],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[May],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Nov],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Oct],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Sep],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.016E3]}) ON COLUMNS  FROM [Model])) WHERE ([Measures].[Trades CCA Sum]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS";
            var    daxFilters = DaxDrillParser.ConvertPivotTableMdxToDaxFilterList(mdxString);
            var    daxDic     = DaxDrillParser.ConvertDaxFilterListToDictionary(daxFilters);

            #region User Friendly Result
            foreach (var pair in daxDic)
            {
                Console.WriteLine(pair.Key + " ---------");
                foreach (var value in pair.Value.Select(x => x.MDX))
                {
                    Console.WriteLine(value);
                }
            }
            #endregion
        }
示例#10
0
        public void ParseTableMdx1()
        {
            string mdxString  = @"SELECT NON EMPTY Hierarchize({DrilldownLevel({[UsageDate].[Usage_MonthAbbrev].[All]},,,INCLUDE_CALC_MEMBERS)}) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY Hierarchize(DrilldownMember(CrossJoin({[Usage].[Inbound or Outbound].[All],[Usage].[Inbound or Outbound].[Inbound or Outbound].AllMembers}, {([Usage].[Call Type].[All])}), [Usage].[Inbound or Outbound].[Inbound or Outbound].AllMembers, [Usage].[Call Type])) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON ROWS  FROM (SELECT ({[UsageDate].[Usage_Year].&[2010],[UsageDate].[Usage_Year].&[2011],[UsageDate].[Usage_Year].&[2012],[UsageDate].[Usage_Year].&[2013],[UsageDate].[Usage_Year].&[2014],[UsageDate].[Usage_Year].&[2015],[UsageDate].[Usage_Year].&[2016],[UsageDate].[Usage_Year].&[2017],[UsageDate].[Usage_Year].&[2018],[UsageDate].[Usage_Year].&[2019],[UsageDate].[Usage_Year].&[2020]},{[Usage].[Country].&[Algeria],[Usage].[Country].&[American samoa]}) ON COLUMNS  FROM [Model]) WHERE ([Measures].[Gross Billed Sum]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS";
            var    daxFilters = DaxDrillParser.ConvertPivotTableMdxToDaxFilterList(mdxString);
            var    daxDic     = DaxDrillParser.ConvertDaxFilterListToDictionary(daxFilters);

            var yearValue    = daxDic["[UsageDate].[Usage_Year]"];
            var yearValueStr = @"[UsageDate].[Usage_Year].&[2010]
[UsageDate].[Usage_Year].&[2011]
[UsageDate].[Usage_Year].&[2012]
[UsageDate].[Usage_Year].&[2013]
[UsageDate].[Usage_Year].&[2014]
[UsageDate].[Usage_Year].&[2015]
[UsageDate].[Usage_Year].&[2016]
[UsageDate].[Usage_Year].&[2017]
[UsageDate].[Usage_Year].&[2018]
[UsageDate].[Usage_Year].&[2019]
[UsageDate].[Usage_Year].&[2020]";

            Assert.AreEqual(yearValueStr, string.Join("\r\n", yearValue.Select(x => x.MDX)));

            var countryValue       = daxDic["[Usage].[Country]"];
            var countryValueString = @"[Usage].[Country].&[Algeria]
[Usage].[Country].&[American samoa]";

            Assert.AreEqual(countryValueString, string.Join("\r\n", countryValue.Select(x => x.MDX)));

            #region User Friendly Result
            foreach (var daxFilter in daxFilters)
            {
                Console.WriteLine("Column={0} ; Table={1} ; Value={2}", daxFilter.ColumnName,
                                  daxFilter.TableName, daxFilter.Value);
            }

            foreach (var pair in daxDic)
            {
                Console.WriteLine(pair.Key + " ---------");
                foreach (var value in pair.Value)
                {
                    Console.WriteLine(value.Value);
                }
            }
            #endregion
        }
示例#11
0
        public void ParseSelectedColumns()
        {
            #region Arrange

            var singDic = new Dictionary <string, string>();
            singDic.Add("[Usage].[Inbound or Outbound].[Inbound or Outbound]",
                        "[Usage].[Inbound or Outbound].&[Inbound]");
            singDic.Add("[Usage].[Call Type].[Call Type]",
                        "[Usage].[Call Type].&[MOC]");
            singDic.Add("[UsageDate].[Usage_Year].[Usage_Year]",
                        "[UsageDate].[Usage_Year].&[2014]");
            singDic.Add("[UsageDate].[Usage_MonthAbbrev].[Usage_MonthAbbrev]",
                        "[UsageDate].[Usage_MonthAbbrev].&[May]");
            #endregion

            #region Parse
            var pivotCellDic = new PivotCellDictionary();
            pivotCellDic.SingleSelectDictionary = singDic;

            var    parser = new DaxDrillParser();
            string commandText;
            using (var tabular = new DaxDrill.Tabular.TabularHelper(serverName, "Roaming"))
            {
                tabular.Connect();
                var selectedColumns = new List <DetailColumn>();
                selectedColumns.Add(new DetailColumn()
                {
                    Name = "Call Type", Expression = "Usage[Call Type]"
                });
                selectedColumns.Add(new DetailColumn()
                {
                    Name = "Call Type Description", Expression = "Usage[Call Type Description]"
                });
                commandText = DaxDrillParser.BuildQueryText(tabular, pivotCellDic, "Gross Billed Sum", 99999, selectedColumns, null);
                tabular.Disconnect();
            }
            #endregion

            #region Assert
            Console.WriteLine(commandText);

            #endregion
        }
示例#12
0
        public void ParseTableMdx4()
        {
            string mdxString  = @"SELECT NON EMPTY Hierarchize(DrilldownMember(CrossJoin({[AsAtDate].[Year].[Year].AllMembers}, {([AsAtDate].[Month].[All])}), [AsAtDate].[Year].[Year].AllMembers, [AsAtDate].[Month])) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY Hierarchize(DrilldownMember(CrossJoin({[Activity].[Fin Activity].[All],[Activity].[Fin Activity].[Fin Activity].AllMembers}, {([ApTradeCreditor].[Supplier].[All])}), {[Activity].[Fin Activity].&[Other Capex]}, [ApTradeCreditor].[Supplier])) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON ROWS  FROM (SELECT ({[AsAtDate].[Month].&[Apr]}) ON COLUMNS , ({[ApTradeCreditor].[Supplier].&[HUAWEI TECHNOLOGIES (AUSTRALIA) PTY LTD]}) ON ROWS  FROM [Model]) WHERE ([ApTradeCreditor].[LiabilityAccount].[All],[ApTradeCreditor].[InvoiceNumber].&[AU1602160],[Measures].[TradeCreditorSum]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS";
            var    daxFilters = DaxDrillParser.ConvertPivotTableMdxToDaxFilterList(mdxString);
            var    daxDic     = DaxDrillParser.ConvertDaxFilterListToDictionary(daxFilters);

            Assert.AreEqual("[AsAtDate].[Month].&[Apr]", daxDic["[AsAtDate].[Month]"][0].MDX);
            Assert.AreEqual("[ApTradeCreditor].[Supplier].&[HUAWEI TECHNOLOGIES (AUSTRALIA) PTY LTD]", daxDic["[ApTradeCreditor].[Supplier]"][0].MDX);

            #region User Friendly Result
            foreach (var pair in daxDic)
            {
                Console.WriteLine(pair.Key + " ---------");
                foreach (var value in pair.Value)
                {
                    Console.WriteLine(value);
                }
            }
            #endregion
        }
示例#13
0
        public string GetDAXQuery(string connString)
        {
            string commandText = "";

            var cnnStringBuilder = new TabularConnectionStringBuilder(connString);

            int maxRecords    = ExcelHelper.GetMaxDrillthroughRecords(rngCell);
            var detailColumns = GetCustomDetailColumns(rngCell);

            using (var tabular = new DaxDrill.Tabular.TabularHelper(
                       cnnStringBuilder.DataSource,
                       cnnStringBuilder.InitialCatalog))
            {
                tabular.Connect();

                // use Table Query if it exists
                // otherwise get the Table Name from the Measure

                string tableQuery = GetCustomTableQuery(rngCell);

                if (string.IsNullOrEmpty(tableQuery))
                {
                    // if table not defined in XML metadata, retrieve entire table
                    string measureName = GetMeasureName(rngCell);
                    commandText = DaxDrillParser.BuildQueryText(tabular,
                                                                pivotCellDic,
                                                                measureName, maxRecords, detailColumns, pivotFieldNames);
                }
                else
                {
                    // if table is defined in XML metadata, retrieve using DAX command
                    commandText = DaxDrillParser.BuildCustomQueryText(tabular,
                                                                      pivotCellDic,
                                                                      tableQuery, maxRecords, detailColumns, pivotFieldNames);
                }

                tabular.Disconnect();
            }

            return(commandText);
        }
示例#14
0
        public void ParseTableMdx5()
        {
            string mdxString  = @"SELECT NON EMPTY Hierarchize(DrilldownMember(CrossJoin({[PaymentDate].[Payment_Year].[All],[PaymentDate].[Payment_Year].[Payment_Year].AllMembers}, {([PaymentDate].[Payment_Month].[All])}), [PaymentDate].[Payment_Year].[Payment_Year].AllMembers, [PaymentDate].[Payment_Month])) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY Hierarchize(DrilldownMember(DrilldownMember(CrossJoin({[Activity].[Dim_1_2].[All],[Activity].[Dim_1_2].[Dim_1_2].AllMembers}, {([Activity].[Dim_1_3].[All],[APPmtDistn].[VendorName].[All])}), [Activity].[Dim_1_2].[Dim_1_2].AllMembers, [Activity].[Dim_1_3]), {[Activity].[Dim_1_3].&[Regulatory Fees]}, [APPmtDistn].[VendorName])) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON ROWS  FROM (SELECT ({[PaymentDate].[Payment_Year].&[2.016E3]}) ON COLUMNS , ({[Activity].[Dim_1_3].&[Regulatory Fees]},{[APPmtDistn].[VendorName].&[AUSTRALIAN COMMUNICATIONS AND MEDIA AUTHORITY]}) ON ROWS  FROM [Model]) WHERE ([APPmtDistn].[InvoiceNum].[All],[Account].[IsCash].&[1],[Measures].[Total Payment Amount Aud]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS";
            var    daxFilters = DaxDrillParser.ConvertPivotTableMdxToDaxFilterList(mdxString);
            var    daxDic     = DaxDrillParser.ConvertDaxFilterListToDictionary(daxFilters);

            Assert.AreEqual("[PaymentDate].[Payment_Year].&[2.016E3]", daxDic["[PaymentDate].[Payment_Year]"][0].MDX);
            Assert.AreEqual("[Activity].[Dim_1_3].&[Regulatory Fees]", daxDic["[Activity].[Dim_1_3]"][0].MDX);
            Assert.AreEqual("[APPmtDistn].[VendorName].&[AUSTRALIAN COMMUNICATIONS AND MEDIA AUTHORITY]",
                            daxDic["[APPmtDistn].[VendorName]"][0].MDX);

            #region User Friendly Result
            foreach (var pair in daxDic)
            {
                Console.WriteLine(pair.Key + " ---------");
                foreach (var value in pair.Value)
                {
                    Console.WriteLine(value);
                }
            }
            #endregion
        }
示例#15
0
        public void ParseTableMdx2()
        {
            string mdxString  = @"SELECT NON EMPTY Hierarchize(DrilldownMember(CrossJoin({[UsageDate].[Usage_Year].[All],[UsageDate].[Usage_Year].[Usage_Year].AllMembers}, {([UsageDate].[Usage_MonthAbbrev].[All])}), [UsageDate].[Usage_Year].[Usage_Year].AllMembers, [UsageDate].[Usage_MonthAbbrev])) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY Hierarchize(DrilldownMember(CrossJoin({[Usage].[Inbound or Outbound].[All],[Usage].[Inbound or Outbound].[Inbound or Outbound].AllMembers}, {([Usage].[Call Type].[All])}), [Usage].[Inbound or Outbound].[Inbound or Outbound].AllMembers, [Usage].[Call Type])) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON ROWS  FROM (SELECT ({[Usage].[Call Type].&[MOC], [Usage].[Call Type].&[GPRS]}) ON COLUMNS  FROM [Model]) WHERE ([Usage].[Country].[All],[Measures].[Gross Billed Sum]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS";
            var    daxFilters = DaxDrillParser.ConvertPivotTableMdxToDaxFilterList(mdxString);
            var    daxDic     = DaxDrillParser.ConvertDaxFilterListToDictionary(daxFilters);

            var    callTypeValue = daxDic["[Usage].[Call Type]"].Select(x => x.MDX);
            string actual        = string.Join("\r\n", callTypeValue);
            string expected      = @"[Usage].[Call Type].&[MOC]
[Usage].[Call Type].&[GPRS]";

            Assert.AreEqual(expected, actual);

            #region User Friendly Result
            foreach (var pair in daxDic)
            {
                Console.WriteLine(pair.Key + " ---------");
                foreach (var value in pair.Value)
                {
                    Console.WriteLine(value);
                }
            }
            #endregion
        }
示例#16
0
        public void ParseHierCellMdx()
        {
            string mdxString = @" ([CounterCcy].[Counter Ccy].&[EUR], [Measures].[Trades CCA Sum], [TranDate].[Tran_MonthAbbrev].&[Apr], [TranDate].[Tran_Year].&[2.016E3], [TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.016E3],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Jul],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Mar],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[May],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Nov],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Oct],[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Sep])";

            var daxFilters = DaxDrillParser.ConvertPivotCellMdxToDaxFilterList(mdxString);
            var daxDic     = DaxDrillParser.ConvertDaxFilterListToDictionary(daxFilters);

            #region User Friendly Result - Dictionary
            foreach (var daxFilter in daxFilters)
            {
                Console.WriteLine("Column={0} ; Table={1} ; Value={2}", daxFilter.ColumnName,
                                  daxFilter.TableName, daxFilter.Value);
            }

            foreach (var pair in daxDic)
            {
                Console.WriteLine(pair.Key + " ---------");
                foreach (var value in pair.Value.Select(x => x.MDX))
                {
                    Console.WriteLine(value);
                }
            }
            #endregion

            #region Assert
            // columns
            Assert.AreEqual("[CounterCcy].[Counter Ccy].&[EUR]", daxDic["[CounterCcy].[Counter Ccy]"][0].MDX);
            Assert.AreEqual("[TranDate].[Tran_MonthAbbrev].&[Apr]", daxDic["[TranDate].[Tran_MonthAbbrev]"][0].MDX);
            Assert.AreEqual("[TranDate].[Tran_Year].&[2.016E3]", daxDic["[TranDate].[Tran_Year]"][0].MDX);

            // hierarchies
            Assert.AreEqual("[TranDate].[Tran_YearMonthDay].&[2.016E3]", daxDic["[TranDate].[Tran_YearMonthDay]"][0].MDX);
            //Assert.AreEqual("[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Jul]", daxDic["[TranDate].[Tran_YearMonthDay]"][1].MDX);
            //Assert.AreEqual("[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Mar]", daxDic["[TranDate].[Tran_YearMonthDay]"][2].MDX);
            #endregion
        }
示例#17
0
        public void SetPivotFieldPage()
        {
            var pageName = DaxDrillParser.CreatePivotFieldPageName("[PrdDate].[Prd_MonthAbbrev].[Prd_MonthAbbrev]", "May");

            Assert.AreEqual("[PrdDate].[Prd_MonthAbbrev].&[May]", pageName);
        }
示例#18
0
 public void ParseHierPivotFilter()
 {
     string value     = "[TranDate].[Tran_YearMonthDay].[Tran_Year].&[2.014E3].&[Mar]";
     var    daxFilter = DaxDrillParser.CreateDaxFilterFromColumn(value);
 }