Sibeesh Passion

Top Menu

  • Home
  • Search
  • About
  • Privacy Policy

Main Menu

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Home
  • Search
  • About
  • Privacy Policy

logo

Sibeesh Passion

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment

  • Build, Deploy, Configure CI &CD Your Static Website in 5 mins

  • Post Messages to Microsoft Teams Using Python

  • Get Azure Blob Storage Blob Metadata Using PowerShell

  • Deploy .net 6 App to Azure from Azure DevOps using Pipelines

.NETASP.NET
Home›.NET›Check Whether a Measure Group is Mapped With Dimension Group

Check Whether a Measure Group is Mapped With Dimension Group

By SibeeshVenu
April 29, 2015
996
0
Share:

Introduction

For the past few months I have been working on a dashboard application where ADOMD is the data source. Our application contains many charts, grids, maps and some other UI controls. We are using MDX queries for generating the widgets used in our application. As you all know, the data must be correct and accurate in every dashboard application. Only then can we get the correct visuals in the charts, grids, maps and so on. So it is necessary to check for the proper data and we must avoid the unwanted calls to the server for fetching the data.

Background

A few days ago I was working on a Bubble Map in High Map. For the map we had to specify the latitude and longitude without any faults in the data. Here we will use a mapping function to check the dimension group and measure group is mapped or not. This will ensure the data is proper and without this check, our MDX query may continue to run. This will definitely make the end users close our application and search for another one. So my idea is to provide a message if the measure group and dimension groups are not mapped, to avoid running the queries for a long time.

What we will do

We will use the following procedure.

  • An ajax call to pass the information to check the process.
  • A controller function where we create a ADOMD connection object and pass the information to the model class
  • A model class where we build and run the query with the necessary parameters.
  • The last step will provide you an information that says whether the given measure group is mapped with the dimension group.
  • Using the code

    So let us start the coding now. As we discussed earlier, first of all we need an ajax call, right?

    An Ajax Call

    The following is our ajax call implementation.
    [csharp]
    var cubeName = ”;
    var measureGroupName = ”;
    var dimensionGroupName = ”;
    var serverName = ‘My server name’;
    var databaseName = ‘My database name’;
    cubeName = ‘My cube name’;
    measureGroupName = sessionStorage.getItem(“measureGroupName”);
    dimensionGroupName = sessionStorage.getItem(“dimensionGroupName”);
    var checkMeasuresMapped =
    {
    cubeName: cubeName,
    measureGroupName: measureGroupName,
    dimensionGroupName: dimensionGroupName,
    serverName: serverName,
    databaseName: databaseName
    };
    $.ajax(
    {
    async: ajaxAsync,
    url: ‘../CheckMeasureGroupMapping/’,
    type: ‘POST’,
    dataType: ‘json’,
    data: JSON.stringify(checkMeasuresMapped),
    contentType: “application/json; charset=utf-8″,
    success: function(data)
    {
    if (data.indexOf(“Error”) > -1)
    {
    $(‘#btnCreate’).css(‘enabled’, ‘false’);
    $(‘#Preview’).html(‘<p style=”color:red;”>Error : ‘ + data.replace(‘Error’, ”) + ‘</p>’);
    }
    else if (data == “Mapped”)
    {
    //Condition satisfied, write your codes here
    ajaxAsync = true;
    }
    else
    {
    $(‘#Preview’).html(‘<p style=”color:red;”>Warning : The given measure is not mapped with the dimension. Please check.</p>’);
    }
    },
    error: function(xhrequest, ErrorText, thrownError)
    {
    console.log(ErrorText + “,” + thrownError);
    $(‘#Preview’).html(‘<p style=”color:red;”>Error : ‘ + ErrorText + ‘</p>’);
    }
    });
    [/csharp]

    Please understand that I have passed all the necessary information. We will list what they all are.

  • Cube Name.
  • Measure Group Name.
  • Dimension Group Name.
  • Server Name.
  • Database Name.
  • Once you are done with the ajax implementation, you will get the information in our controller, right? That is how the ajax call works. If you are new to the ajax calls, please refer to the following links.

  • http://www.w3schools.com/ajax/
  • http://www.w3schools.com/jquery/ajax_ajax.asp
  • Controller Function

    I hope you are all done with the ajax implementation, now we will move on to the next part. Please refer to the following code.

    [csharp]
    ///<summary>
    ///This method is used to find whether the given measure is mapped to the dimension
    ///<param name=”cubeName”></param>
    ///<param name=”measureGroupName”></param>
    ///<param name=”dimensionGroupName”></param>
    ///</summary>
    [HandleError]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult CheckMeasureGroupMapping(string cubeName, string measureGroupName, string dimensionGroupName, string serverName, string databaseName) {
    try
    {
    DataTable dt = new DataTable();
    dt = adomdConn.CheckMeasureGroupMapping(cubeName, measureGroupName, dimensionGroupName, serverName, databaseName);
    if (dt.Rows.Count < 1)
    {
    return Json(“The given measure is not mapped with the dimension. Please check.”, JsonRequestBehavior.AllowGet);
    }
    else
    {
    return Json(“Mapped”, JsonRequestBehavior.AllowGet);
    }
    }
    catch (AdomdErrorResponseException ex)
    {
    string errrorText = “Query Error” + System.Web.HttpUtility.HtmlEncode(ex.Message);
    return Json(errrorText, JsonRequestBehavior.AllowGet);
    }
    }
    [/csharp]

    Here CheckMeasureGroupMapping is our ActionResult and we are passing the information to our model class. If our conditions are satisfied then the preceding function will return the rows in a datatable. With the row count of that data table we can arrive at our conclusion.

    Model Function

    Now we are in the final part, since we have the necessary parameters in our model class, it is time to build the query and run it in the ADOMD server. So the following is the function to do that.
    [csharp]
    public DataTable CheckMeasureGroupMapping(string cubeName, string measureGroupName, string dimensionGroupName, string serverName, string databaseName)
    {
    try
    {
    string query = string.Empty;
    string queryBefore = string.Empty;
    queryBefore = “SELECT [MEASUREGROUP_NAME] AS [MEASUREGROUP],[MEASUREGROUP_CARDINALITY],[DIMENSION_UNIQUE_NAME] AS [DIM],[DIMENSION_GRANULARITY] AS [DIM_KEY],[DIMENSION_CARDINALITY],[DIMENSION_IS_VISIBLE] AS [IS_VISIBLE],[DIMENSION_IS_FACT_DIMENSION] AS [IS_FACT_DIM] FROM $system.MDSCHEMA_MEASUREGROUP_DIMENSIONS WHERE [CUBE_NAME] = {cubeName} AND [MEASUREGROUP_NAME] ={measureGroupName} AND [DIMENSION_UNIQUE_NAME]={dimensionGroupName}”;
    query = queryBefore.Replace(“{cubeName}”, “‘” + cubeName + “‘”).Replace(“{measureGroupName}”, “‘” + measureGroupName + “‘”).Replace(“{dimensionGroupName}”, “‘” + dimensionGroupName + “‘”);
    StringBuilder sbConnectionString = new StringBuilder();
    sbConnectionString.Append(“Provider=MSOLAP;data source=”);
    sbConnectionString.Append(serverName + “;initial catalog=” + databaseName + “;Integrated Security=SSPI;Persist Security Info=False;”);
    using(AdomdConnection conn = new AdomdConnection(sbConnectionString.ToString()))
    {
    conn.Open();
    using(AdomdCommand cmd = new AdomdCommand(query, conn))
    {
    DataTable dt = new DataTable();
    AdomdDataAdapter da = new AdomdDataAdapter(cmd);
    da.Fill(dt);
    return dt;
    }
    }
    }
    catch (AdomdErrorResponseException ex)
    {
    throw;
    }
    }
    [/csharp]

    As you all can see, the following is the query for determining whether the given measure group is mapped with the dimension group or not.

    [sql]
    SELECT
    [MEASUREGROUP_NAME] AS [MEASUREGROUP],
    [MEASUREGROUP_CARDINALITY],
    [DIMENSION_UNIQUE_NAME] AS [DIM],
    [DIMENSION_GRANULARITY] AS [DIM_KEY],
    [DIMENSION_CARDINALITY],
    [DIMENSION_IS_VISIBLE] AS [IS_VISIBLE],
    [DIMENSION_IS_FACT_DIMENSION] AS [IS_FACT_DIM]
    FROM
    $system.MDSCHEMA_MEASUREGROUP_DIMENSIONS
    WHERE
    [CUBE_NAME] = {cubeName}
    AND [MEASUREGROUP_NAME] = {measureGroupName}
    AND [DIMENSION_UNIQUE_NAME] = {dimensionGroupName} “;
    [/sql]

    We are running this query with the parameters and we will return the result to our controller. At the end we will check the condition as we have shown in the ajax call.
    [js]
    if (data.indexOf(“Error”) > -1)
    {
    $(‘#btnCreate’).css(‘enabled’, ‘false’);
    $(‘#Preview’).html(‘<p style=”color:red;”>Error : ‘ + data.replace(‘Error’, ”) + ‘</p>’);
    }
    else if (data == “Mapped”)
    {
    //Condition satisfied, write your codes here
    ajaxAsync = true;
    }
    else
    {
    $(‘#Preview’).html(‘<p style=”color:red;”>Warning : The given measure is not mapped with the dimension. Please check.</p>’);
    }
    [/js]

    So we are done with this requirement.

    Happy coding!

    Conclusion

    I hope you liked my article. Please share your valuable feedbacks. It means a lot.

    Additional references

  • How to Convert Microsoft ADOMD Data Source to JSON
  • Convert CellSet to HTML Table and From HTML to JSON and to Array
  • Convert Microsoft ADOMD Cell Set to JSON
  • Output

    If the given measure group is not mapped with the measure group, you will get the following as output in your preview area.

    Points of interests

    ADOMD, ADOMD Measure, ADOMD Dimension, ADOMD Measure Groups, ADOMD Dimension Group, Mapping measure group and dimension group.

    TagsADOMDADOMD DimensionADOMD Dimension GroupADOMD MeasureADOMD Measure GroupsMapping measure group and dimension group.
    Previous Article

    Creating a Simple Windows Application Using Azure

    Next Article

    Create a Combo Chart and Make Your ...

    0
    Shares
    • 0
    • +
    • 0
    • 0
    • 0

    SibeeshVenu

    I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer.

    Related articles More from author

    • Q&A

      CellSetGrid Implementation in VS 2012 or later

      July 14, 2015
      By SibeeshVenu
    • .NETASP.NETC#JQueryJsonMicrosoft ADOMD

      Convert Microsoft ADOMD Cell Set to JSON

      March 29, 2015
      By SibeeshVenu
    • Excel Export In MDX
      .NETASP.NETMDX QuerySQL

      Export MDX Result As Excel

      October 28, 2015
      By SibeeshVenu
    • .NETASP.NETC#JsonMicrosoft ADOMD

      How to Convert Microsoft ADOMD Data Source to JSON

      January 29, 2015
      By SibeeshVenu
    • .NETASP.NETC#JsonMicrosoft ADOMDMicrosoft Technologies

      Convert CellSet to HTML Table and From HTML to JSON and to Array

      October 29, 2014
      By SibeeshVenu
    • .NETASP.NETBlogC#

      Calling a Webmethod Using Jquery Ajax

      May 31, 2015
      By SibeeshVenu
    0

    My book

    Asp Net Core and Azure with Raspberry Pi Sibeesh Venu

    YouTube

    MICROSOFT MVP (2016-2022)

    profile for Sibeesh Venu - Microsoft MVP

    Recent Posts

    • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment
    • Build, Deploy, Configure CI &CD Your Static Website in 5 mins
    • Easily move data from one COSMOS DB to another
    • .NET 8 New and Efficient Way to Check IP is in Given IP Range
    • Async Client IP safelist for Dot NET
    • Post Messages to Microsoft Teams Using Python
    • Get Azure Blob Storage Blob Metadata Using PowerShell
    • Deploy .net 6 App to Azure from Azure DevOps using Pipelines
    • Integrate Azure App Insights in 1 Minute to .Net6 Application
    • Azure DevOps Service Connection with Multiple Azure Resource Group

    Tags

    Achievements (35) Angular (14) Angular 5 (7) Angular JS (15) article (10) Article Of The Day (13) Asp.Net (14) Azure (65) Azure DevOps (10) Azure Function (10) Azure IoT (7) C# (17) c-sharp corner (13) Career Advice (11) chart (11) CSharp (7) CSS (7) CSS3 (6) HighChart (10) How To (9) HTML5 (10) HTML5 Chart (11) Interview (6) IoT (11) Javascript (10) JQuery (82) jquery functions (9) JQWidgets (15) JQX Grid (17) Json (7) Microsoft (8) MVC (20) MVP (9) MXChip (7) News (18) Office 365 (7) Products (10) SQL (20) SQL Server (15) Visual Studio (10) Visual Studio 2017 (7) VS2017 (7) Web API (12) Windows 10 (7) Wordpress (9)
    • .NET
    • Achievements
    • ADO.NET
    • Android
    • Angular
    • Arduino
    • Article Of The Day
    • ASP.NET
    • Asp.Net Core
    • Automobile
    • Awards
    • Azure
    • Azure CDN
    • azure devops
    • Blockchain
    • Blog
    • Browser
    • C-Sharp Corner
    • C#
    • Career Advice
    • Code Snippets
    • CodeProject
    • Cognitive Services
    • Cosmos DB
    • CSS
    • CSS3
    • Data Factory
    • Database
    • Docker
    • Drawings
    • Drill Down Chart
    • English
    • Excel Programming
    • Exporting
    • Facebook
    • Fun
    • Gadgets
    • GitHub
    • GoPro
    • High Map
    • HighChart
    • How to
    • HTML
    • HTML5
    • Ignite UI
    • IIS
    • Interview
    • IoT
    • JavaScript
    • JQuery
    • jQuery UI
    • JQWidgets
    • JQX Grid
    • Json
    • Knockout JS
    • Linux
    • Machine Learning
    • Malayalam
    • Malayalam Poems
    • MDX Query
    • Microsoft
    • Microsoft ADOMD
    • Microsoft MVP
    • Microsoft Office
    • Microsoft Technologies
    • Microsoft Windows
    • Microsoft Windows Server
    • Mobile
    • MongoDB
    • Monthly Winners
    • MVC
    • MVC Grid
    • MySQL
    • News
    • Node JS
    • npm
    • Number Conversions
    • October 2015
    • Office 365
    • Office Development
    • One Plus
    • Outlook
    • Page
    • PHP
    • Poems
    • PowerShell
    • Products
    • Q&A
    • Raspberry PI
    • React
    • SEO
    • SharePoint
    • Skype
    • Social Media
    • Software
    • Spire.Doc
    • Spire.PDF
    • Spire.XLS
    • SQL
    • SQL Server
    • SSAS
    • SSMS
    • Storage In HTML5
    • Stories
    • Third Party Software Apps
    • Tips
    • Tools
    • Translator Text
    • Uncategorized
    • Unit Testing
    • UWP
    • VB.Net
    • Videos
    • Virtual Machine
    • Visual Studio
    • Visual Studio 2017
    • Wamp Server
    • Web API
    • Web Platform Installer
    • Webinars
    • WebMatrix
    • Windows 10
    • Windows 7
    • Windows 8.1
    • Wordpress
    • Writing

    ABOUT ME

    I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer. If you would like to know more about me, you can read my story here.

    Contact Me

    • info@sibeeshpassion.com

    Pages

    • About
    • Search
    • Privacy Policy
    • About
    • Search
    • Privacy Policy
    © Copyright Sibeesh Passion 2014-2025. All Rights Reserved.
    Go to mobile version