Find (Method)

Applies To:

QueryLabel object

Description:

Finds and returns a collection of members matching the Member argument.

Syntax:

Expression.Find(MemberName as String, IncludeSharedMembers as Boolean)

The "*" character may be used as a wild-card in the MemberName argument.

If an alias table is in use, the member may be specified using the aliases, for example, "Cola" instead of "100-10".

The IncludeSharedMembers argument specifies whether to include shared members in the results of the search or not.

Example 1:

This example shows how to determine which returned members to add using the Find (Method) and Add (Method):

var prodLabel = Sections["Query"].Rows["Product"];

// Find and add all instances of members starting with 100- to the Product label
// Results are returned as an anonymous collection
var results = prodLabel.Find("100-*, true);
for (var i = 1; i <= results.Count; i++) {
    var m = results[i].Name;
    prodLabel.Add(m, bqOlapSelectorMember);
}

Example 2:

This example shows how to use the Find (Method) with various control objects:

//Clear List Box
ActiveDocument.Sections["QueryLabel - Find"].Shapes["ListBox1"].RemoveAll()

//Get Dimension to search
var DimSel = ActiveDocument.Sections["QueryLabel - Find"].Shapes["DropDown1"].SelectedIndex
var strDimension = ActiveDocument.Sections["Query"].Catalog.Dimensions.Item(DimSel).Name

//Get Include Shared Members Value
var strIncludeSharedMembers = false
if (ActiveDocument.Sections["QueryLabel - Find"].Shapes["RadioButton1"].Checked)
	strIncludeSharedMembers = true
else if (ActiveDocument.Sections["QueryLabel - Find"].Shapes["RadioButton2"].Checked)
	strIncludeSharedMembers = false

//Get Text to search for
var strSearchMember = ActiveDocument.Sections["QueryLabel - Find"].Shapes["TextBox5"].Text

//Find using user entered search string and write to Results set
var Results = ActiveDocument.Sections["Query"].Rows[strDimension].Find(strSearchMember, strIncludeSharedMembers)

//Get the hits from QueryLabel.FindResults collection
var intNumOfHits = Results.Count

//Set Counter
var intCount = 1

//Loop throught Items() and populate listbox
do 
{
	if (ActiveDocument.Sections["QueryLabel - Find"].Shapes["RadioButton3"].Checked)
		ActiveDocument.Sections["QueryLabel - Find"].Shapes["ListBox1"].Add(Results[intCount].Name)
	else if (ActiveDocument.Sections["QueryLabel - Find"].Shapes["RadioButton4"].Checked)
		ActiveDocument.Sections["QueryLabel - Find"].Shapes["ListBox1"].Add(Results[intCount].UniqueName)
	intCount ++
}
while (intCount <= intNumOfHits );