Skip to main content

HierarchyQuery Class

The HierarchyQuery class represents a hierarchy of symbols in a dimension that can be used in memory or output to a worksheet.

Property Summary

Property IncludeDescriptions As Boolean

Sub/Function Summary

  • Sub AddSymbolSpec(symbolSpec As String, [root As String])
  • Function Run() As QueryResult
  • Sub RunToWorksheet([worksheetName As String], [cell As String])

Properties

Parameter Description

IncludeDescriptions

Property IncludeDescriptions As Boolean

Sets whether the query results will return a column for the symbol description and the parent description.  By default, the value is FALSE.

Subs/Functions

Parameter Description

AddSymbolSpec

Sub AddSymbolSpec(symbolSpec As String, [root As String])

Adds a symbol spec representing the hierarchy you wish to query.

  • Parameters:
    • symbolSpec – String representing a single symbol spec. For example: TRIALBAL#99.
    • root – Optional string representing the root symbol name for the specified symbol.
  • Errors:

    ErrorCode.INVALID_PARAMETER – This error is thrown when the symbol spec is invalid or when the root is not a valid root for the specified symbol.

Run

Function Run() As QueryResult

Runs the hierarchy query and returns the results in a QueryResult class.

  • Errors:

    ErrorCode.INVALID_PARAMETER – This error is thrown when no symbol spec has been specified.

RunToWorksheet

Sub RunToWorksheet([worksheetName As String], [cell As String])

Runs a hierarchy query and places the results into the specified worksheet and cell location.

  • Parameters:
    • worksheetName  – optional string representing the name of the worksheet to place the results.  If the worksheet does not exist, it will be created.  If the worksheetName parameter is not specified, the current worksheet will be used.
    • cell – optional string representing the cell location to begin the symbol query. If the cell parameter is not specified, the default cell location A1 will be used.
  • Errors:ErrorCode.INVALID_PARAMETER – This error is thrown when the query is invalid or when the specified worksheet name or cell are invalid.

Sample Usage:

Sub RunHierarchyQuery()

On Error GoTo ErrorHandler

Dim result As Longview.QueryResult

Dim query As Longview.HierarchyQuery

Set query = New Longview.HierarchyQuery

Set result = query.Run()

Dim row As Long

Dim column As Long

For row = 1 to result.RowCount

For column = 1 to result.ColumnCount

‘ Place results of symbol query into cells of the worksheet manually

Range(“A1”).Offset(row – 1, column – 1).Value = result.GetCellValue(row, column)

Next column

Next row

ErrorHandler:

If Err.Number <> 0 Then

MsgBox “Unable to run Hierarchy Query (“ & Err.Number & “) – “ &

Err.Description

End If

End Sub

Was this article helpful?

We're sorry to hear that.