The requested page is not available for the requested platform. You are viewing the content for Default platform.

How to: Apply Master Filtering in Code in OLAP Mode

The following example demonstrates how to apply filtering for dashboard items that act as a master filter in OLAP mode.

In this example, the DashboardViewer.SetMasterFilter method is used to select the required cards in the Card dashboard item. Note that unique names of OLAP members are used instead of values.

using System.Collections.Generic;
using System.Windows.Forms;
using System.Collections;

namespace Dashboard_SetMasterFilter_OLAP {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            // Loads a dashboard from an XML file.
            dashboardViewer1.LoadDashboard(@"..\..\Data\Dashboard.xml");

            // Creates two sets of OLAP members' unique names to select corresponding cards 
            // in the Card dashboard item.
            List<object> cardValues1 = new List<object>();
            cardValues1.AddRange(new[] { "[Date].[Calendar Year].&[2001]",
                "[Date].[Calendar Quarter of Year].&[CY Q4]" });
            List<object> cardValues2 = new List<object>();
            cardValues2.AddRange(new[] { "[Date].[Calendar Year].&[2002]",
                "[Date].[Calendar Quarter of Year].&[CY Q1]" });
            List<IList> selectedCards = new List<IList>(new[] { cardValues1, cardValues2 } );

            // Selects specified cards in the Card dashboard item.
            dashboardViewer1.SetMasterFilter("cardDashboardItem1", selectedCards);
        }      
    }
}
See Also