Jump to content
We've recently updated our Privacy Statement, available here ×
  • Schema Workbench - Testing MDX Query


    Guest
    • Product: JasperReports® Server

    This guide is based on FoodMart data source, a MySQL database example provided when installing JasperReports Server. The purpose is to get familiar with MDX syntax.

    1. Launch Jaspersoft OLAP Schema Workbench and open the OLAP schema created from the previous guide Creating an OLAP Schema.
    2. Click on MDX Query icon.

      Schema_Workbench_Testing_MDX_Query_1.JPG.7d61e994aa2e39a5eda5526d61ebe862.JPG

    Measures and Dimension

    1. Try this basic MDX query:

      SELECT {
        [Measures].[product number],
        [Measures].[class number]
      } ON COLUMNS,
      {
        [Product]
      } ON ROWS
      FROM Products

      [product number] and [class number] are measures.
      [Product] is a dimension.
      Products is a cube.

    2. Click on Execute to display the result:

      Schema_Workbench_Testing_MDX_Query_2.JPG.c5e5d06b95149d40c9a7296e5b16eb11.JPG


    ON ROWS - ON COLUMNS

    Previously, measures were set as COLUMNS and Product dimension set as ROWS. But it can be switched: measures set as ROWS and Product Dimension set as COLUMNS.

    1. Try switching ON COLUMNS and ON ROWS. Do Execute to display the result:

      Schema_Workbench_Testing_MDX_Query_3.JPG.0ef311995f0939f6de30dbaaf78de588.JPG

    Dimension's Methods

    [dimension].children

    SELECT {
        [Measures].[product number],
        [Measures].[class number]
    } ON COLUMNS,
    {
        [Product].children
    } ON ROWS FROM Products
    

    Schema_Workbench_Testing_MDX_Query_4.JPG.9bbe9ceacc469ea7462f41a755a870d1.JPG

    [dimension].firstChild or .lastChild

    SELECT {
        [Measures].[product number],
        [Measures].[class number]
    } ON COLUMNS, {
        [Product].firstChild // or [Product].lastChild
    } ON ROWS FROM Products
    

    Schema_Workbench_Testing_MDX_Query_5.JPG.be526fc1ddd2991809a233fea270b938.JPG
    Schema_Workbench_Testing_MDX_Query_6.JPG.b9ed16f627c26f627699ae4b33d6ceec.JPG

    Drilling Dimension

    Reminder: the Product dimension's hierarchy is Product > Brand > Name > SKU.

    You can drill a dimension to focus the display on particular values. You just have to know your Brand, Name or SKU value.

    SELECT {
        [Measures].[product number],
        [Measures].[class number]
    } ON COLUMNS, {
        [Product],
        [Product].[Tri-State].[Tri-State Dried Mushrooms],
        [Product].[Big City],
        [Product].Queen.children
    } ON ROWS FROM Products
    

    Schema_Workbench_Testing_MDX_Query_7.JPG.5500f087a069dc05d38db6989ff10009.JPG

    Generating default MDX queries

    Since the new Jaspersoft OLAP Schema Workbench 3.5.4 released, you have a new button to generate MDX queries.

    • Click on MDX Query icon. Now just beside of Save As icon, click on Generate MDX Queries icon. Here is below a generated query:

      SELECT [Measures].AllMembers ON COLUMNS,
             Hierarchize([Product].[All Products].Children) ON ROWS
        FROM [Products];
      

    Schema_Workbench_Testing_MDX_Query_8.JPG.b40056f7236dfbd1f5d60bf365b4beda.JPG

    Notes

    Square brackets

    • If your OLAP schema contains items named with special characters such as space in "Big City", you have to use square brackets [ ]. Example: [big City].
    • If not, [ ] are not necessary. Example: Queen or [Queen].

    See also...


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...