<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MDX Query &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/tag/mdx-query/feed/" rel="self" type="application/rss+xml" />
	<link>https://sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 11 Jul 2018 16:26:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>MDX Query &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Find Datatype Of Each Measures In SSAS MDX Queries</title>
		<link>https://sibeeshpassion.com/find-datatype-of-each-measures-in-ssas-mdx-queries/</link>
					<comments>https://sibeeshpassion.com/find-datatype-of-each-measures-in-ssas-mdx-queries/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 22 Feb 2016 00:00:20 +0000</pubDate>
				<category><![CDATA[MDX Query]]></category>
		<category><![CDATA[SSAS]]></category>
		<category><![CDATA[Datatype Of Each Measures]]></category>
		<category><![CDATA[DMV Query]]></category>
		<category><![CDATA[MDX]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=11226</guid>

					<description><![CDATA[In this post we will see how we can get the datatype of each measures we use in our SSAS MDX Queries. This post may be helpful if you are working with SSAS cubes especially you need to work with the data you gets from the cubes like formatting the data, assigning the data as grid data source or formulate the data to any other form. I have got a requirement to show the cube data as a grid, So I was needed to know the types of each measures user selects so that I can assign the grid column [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can get the datatype of each measures we use in our <a href="http://sibeeshpassion.com/category/ssas/" target="_blank">SSAS </a><a href="http://sibeeshpassion.com/category/microsoft-adomd/mdx-query/" target="_blank">MDX Queries</a>. This post may be helpful if you are working with SSAS cubes especially you need to work with the data you gets from the cubes like formatting the data, assigning the data as grid data source or formulate the data to any other form. I have got a requirement to show the cube data as a grid, So I was needed to know the types of each measures user selects so that I can assign the grid column types accordingly. There are few many ways we can find the types of measures, here I am going to discuss that with you. I hope you will like this. </p>
<p><strong>Background</strong></p>
<p>I had gone through this requirement and I could do this in time with the help of Mr.GregGalloway (Stack overflow user). You can find my question <a href="http://stackoverflow.com/questions/34528747/find-data-type-of-measures-in-cube-using-mdx-queries" target="_blank">here </a>in stack overflow. </p>
<p>If your cube has data with the types of string and numbers alone, finding the types will be too easy. Now before going through the processes listed in this article, if you don&#8217;t have only string and numbers as the types in the cube, this <a href="http://stackoverflow.com/questions/9951314/retrieving-data-type-of-measures-from-an-mdx-query-cellset-in-c-sharp" target="_blank">post </a>will definitely help you.</p>
<blockquote><p>If you are looking for some sample stored procedures that will help you with your development with your analysis services, you can always see it <a href="https://asstoredprocedures.codeplex.com/" target="_blank">here: ASSP &#8211; Analysis Services Stored Procedure Project</a>.
</p></blockquote>
<p><strong>Using the code</strong></p>
<p>Here we are going to create a function which accepts server name, database name, and the measure name collection in which we need to find out what type it is. The core part of this function will be a DMV query which we can run against our SSAS cube. The query will be as follows. </p>
<p>[sql]<br />
select [CATALOG_NAME],[CUBE_NAME],MEASURE_NAME, DATA_TYPE,EXPRESSION,MEASURE_IS_VISIBLE,MEASUREGROUP_NAME,MEASURE_DISPLAY_FOLDER,DEFAULT_FORMAT_STRING  from $system.mdschema_measures<br />
[/sql]</p>
<p>Now before going further, please make sure that you have included AnalysisServices Adomd Client.</p>
<p>[csharp]<br />
using Microsoft.AnalysisServices.AdomdClient;<br />
[/csharp]</p>
<p>Now we will create the function which will give you the data about the datatypes of your measures. </p>
<p>[csharp]<br />
#region Return the data types of measures<br />
        /// &lt;summary&gt;<br />
        /// FindMeasureDataTypes-Find the measure type whetehr it is a currency or a percentage or a number<br />
        /// &lt;/summary&gt;<br />
        /// &lt;param name=&quot;serverName&quot;&gt;&lt;/param&gt;<br />
        /// &lt;param name=&quot;databaseName&quot;&gt;&lt;/param&gt;<br />
        /// &lt;param name=&quot;myMeasureCollection&quot;&gt;&lt;/param&gt;<br />
        public DataTable FindMeasureDataTypes(string serverName, string databaseName, string myMeasureCollection)<br />
        {</p>
<p>            try<br />
            {<br />
                string res = string.Empty;<br />
                List&lt;string&gt; myMeasures = new List&lt;string&gt;();</p>
<p>                //Buiding the connection string start<br />
                StringBuilder sbConnectionString = new StringBuilder();<br />
                sbConnectionString.Append(&quot;Provider=MSOLAP;data source=&quot;);<br />
                sbConnectionString.Append(serverName + &quot;;initial catalog=&quot; + databaseName + &quot;;Integrated Security=SSPI;Persist Security Info=False;&quot;);<br />
                //Buiding the connection string start</p>
<p>                AdomdConnection conn = new AdomdConnection(sbConnectionString.ToString());<br />
                myMeasures = myMeasureCollection.Split(new string[] { &quot;||&quot; }, StringSplitOptions.None).ToList();</p>
<p>                for (int i = 0; i &lt; myMeasures.Count; i++)<br />
                {<br />
                    //Format the measure name<br />
                    if (i == 0)<br />
                        res += &quot;MEASURE_NAME =&#8217;&quot; + myMeasures[i].Replace(&quot;[Measures].&quot;, &quot;&quot;).Replace(&quot;[&quot;, &quot;&quot;).Replace(&quot;]&quot;, &quot;&quot;) + &quot;&#8217;&quot;;<br />
                    else<br />
                        res += &quot; OR MEASURE_NAME =&#8217;&quot; + myMeasures[i].Replace(&quot;[Measures].&quot;, &quot;&quot;).Replace(&quot;[&quot;, &quot;&quot;).Replace(&quot;]&quot;, &quot;&quot;) + &quot;&#8217;&quot;;<br />
                }</p>
<p>                string query = &quot;select [CATALOG_NAME],[CUBE_NAME],MEASURE_NAME, DATA_TYPE,EXPRESSION,MEASURE_IS_VISIBLE,MEASUREGROUP_NAME,MEASURE_DISPLAY_FOLDER,DEFAULT_FORMAT_STRING  from $system.mdschema_measures where &quot; + res;<br />
                using (AdomdCommand cmd = new AdomdCommand(query, conn))<br />
                {<br />
                    DataTable tblMeasureType = new DataTable();<br />
                    AdomdDataAdapter da = new AdomdDataAdapter(cmd);<br />
                    da.Fill(tblMeasureType);<br />
                    return tblMeasureType;<br />
                }</p>
<p>            }<br />
            catch (Exception)<br />
            {<br />
                return null;<br />
            }<br />
        }</p>
<p>        #endregion<br />
[/csharp]</p>
<p>So in the table <em>tblMeasureType</em>, we will get the data. In the column <em>DEFAULT_FORMAT_STRING </em>, you can see the actual type of your measure. It will show as &#8216;Currency&#8217; if it is a currency type and &#8216;Percentage&#8217; if it is a percentage type and &#8216;#,##&#8217; for the numbers. The <em>DEFAULT_FORMAT_STRING </em> actually describes each measures which are all available in the cube. And <em>DEFAULT_FORMAT_STRING </em>rowset contains the following columns. </p>
<li>CATALOG_NAME</li>
<li>SCHEMA_NAME</li>
<li>CUBE_NAME</li>
<li>MEASURE_NAME</li>
<li>MEASURE_UNIQUE_NAME</li>
<li>MEASURE_CAPTION</li>
<li>MEASURE_GUID</li>
<li>MEASURE_AGGREGATOR</li>
<li>DATA_TYPE</li>
<li>NUMERIC_PRECISION</li>
<li>NUMERIC_SCALE</li>
<li>MEASURE_UNITS</li>
<li>DESCRIPTION</li>
<li>EXPRESSION</li>
<li>MEASURE_IS_VISIBLE</li>
<li>LEVELS_LIST</li>
<li>MEASURE_NAME_SQL_COLUMN_NAME</li>
<li>MEASURE_UNQUALIFIED_CAPTION</li>
<li>MEASUREGROUP_NAME</li>
<li>MEASURE_DISPLAY_FOLDER</li>
<li>DEFAULT_FORMAT_STRING</li>
<p>You can always check <a href="https://msdn.microsoft.com/en-us/library/ms126250.aspx" target="_blank">here </a>to see for more information about <em>MDSCHEMA_MEASURES Rowset</em>.</p>
<p>As you can see the function accepts one parameter called <em>myMeasureCollection</em>, this is the collection of our measures and we are formatting the same as follows. </p>
<p>[csharp]<br />
 for (int i = 0; i &lt; myMeasures.Count; i++)<br />
                {<br />
                    //Format the measure name<br />
                    if (i == 0)<br />
                        res += &quot;MEASURE_NAME =&#8217;&quot; + myMeasures[i].Replace(&quot;[Measures].&quot;, &quot;&quot;).Replace(&quot;[&quot;, &quot;&quot;).Replace(&quot;]&quot;, &quot;&quot;) + &quot;&#8217;&quot;;<br />
                    else<br />
                        res += &quot; OR MEASURE_NAME =&#8217;&quot; + myMeasures[i].Replace(&quot;[Measures].&quot;, &quot;&quot;).Replace(&quot;[&quot;, &quot;&quot;).Replace(&quot;]&quot;, &quot;&quot;) + &quot;&#8217;&quot;;<br />
                }<br />
[/csharp]</p>
<p>The <em>myMeasureCollection</em> is a string variable which has the values in the format of [Measures].[My Measure 1]||[Measures].[My Measure 2]||[Measures].[My Measure 3]. That is why we are splitting the values with || as follows.</p>
<p>[csharp]<br />
 myMeasures = myMeasureCollection.Split(new string[] { &quot;||&quot; }, StringSplitOptions.None).ToList();<br />
[/csharp]</p>
<p>I hope everything is clear. Have a happy coding. </p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Have you ever wanted to do this requirement? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/find-datatype-of-each-measures-in-ssas-mdx-queries/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Filters in MDX Queries</title>
		<link>https://sibeeshpassion.com/filters-in-mdx-queries/</link>
					<comments>https://sibeeshpassion.com/filters-in-mdx-queries/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 06 Jul 2015 10:11:21 +0000</pubDate>
				<category><![CDATA[MDX Query]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[Filter Conditions in MDX]]></category>
		<category><![CDATA[Filtering in MDX]]></category>
		<category><![CDATA[Free source code]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[MDX Filter]]></category>
		<category><![CDATA[ms-sql-server]]></category>
		<category><![CDATA[OLAP]]></category>
		<category><![CDATA[SQL-server-2005]]></category>
		<category><![CDATA[SQL-Server-2008]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=6321</guid>

					<description><![CDATA[Introduction Today we will learn about filter conditions in MDX queries. There are so many conditions in MDX as we have SQL. I am going to discuss most used filter conditions in MDX. I hope you will like it. Background For the past few days I am working on the MDX queries. Since my applications data source were ADOMD data source, It was must to learn about MDX queries. If you are new to ADOMD, you can find out some tips here: ADOMD Tips What is MDX? Before going to start, we will see what MDX is? MDX stands for [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span style="color: #ff6600;"><strong>Introduction</strong></span></p>
<p>Today we will learn about filter conditions in MDX queries. There are so many conditions in MDX as we have SQL. I am going to discuss most used filter conditions in MDX. I hope you will like it.</p>
<p><span style="color: #ff6600;"><strong>Background</strong></span></p>
<p>For the past few days I am working on the MDX queries. Since my applications data source were ADOMD data source, It was must to learn about MDX queries. If you are new to ADOMD, you can find out some tips here: <a href="http://sibeeshpassion.com/category/microsoft-adomd/" target="_blank">ADOMD Tips</a></p>
<p><span style="color: #ff6600;"><strong>What is MDX?</strong></span></p>
<p>Before going to start, we will see what MDX is?</p>
<li>MDX stands for Multidimensional Expression</li>
<li>It is a query language for OLAP databases like SQL for relational databases</li>
<li> It is also a calculation language</li>
<li>Its syntax is similar to spreadsheet formulas</li>
<p>If you are completely new to MDX, you can read basics <a href="http://www.codeproject.com/Articles/710387/Learn-to-Write-Custom-MDX-Query-First-Time" target="_blank">here</a></p>
<p><span style="color: #ff6600;"><strong>Expressions and Equivalent in MDX</strong></span></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/MDXFilterExpression1.png" alt="" /></p>
<p>Now we will use this conditions in the MDX queries.I hope you are aware of MDX query basics now.</p>
<p><span style="color: #ff6600;"><strong>MDX Filter Expression Examples</strong></span></p>
<p><strong>To Check whether dimension value is empty </strong><br />
To check whether a dimension value is empty or not, you need to add a filter condition as follows.<br />
[sql]<br />
{FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Trim([My Dimension Group].[Dimension Name].CurrentMember.Name) = &#8221;)}<br />
[/sql]</p>
<p><strong>To Check whether dimension value is Not Empty </strong><br />
To check whether a dimension value is not empty or not, you need to add a filter condition as follows.<br />
[sql]<br />
{FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Trim([My Dimension Group].[Dimension Name].CurrentMember.Name) &lt;&gt; &#8221;)}<br />
[/sql]</p>
<p><strong>To Check whether dimension value Contains a particular value </strong><br />
To check whether a dimension value Contains a particular value, you need to add a filter condition as follows.<br />
[sql]<br />
{FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Instr([My Dimension Group].[Dimension Name].CurrentMember.Name, &#8216;My String Value&#8217;) &gt; 0)}<br />
[/sql]</p>
<p><strong>To Check whether dimension value Does Not Contains a particular value </strong><br />
To check whether a dimension value Does Not Contains a particular value, you need to add a filter condition as follows.<br />
[sql]<br />
-{FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Instr([My Dimension Group].[Dimension Name].CurrentMember.Name, &#8216;My String Value&#8217;) &gt; 0)}<br />
[/sql]</p>
<p><strong>To Check whether dimension value Starts With a particular value </strong><br />
To check whether a dimension value Starts With  a particular value, you need to add a filter condition as follows.<br />
[sql]<br />
{FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Left([My Dimension Group].[Dimension Name].CurrentMember.Name, 5) = &#8216;My String Value&#8217;)}<br />
[/sql]</p>
<p><strong>To Check whether dimension value Ends With a particular value </strong><br />
To check whether a dimension value Ends With  a particular value, you need to add a filter condition as follows.<br />
[sql]<br />
{FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Right([My Dimension Group].[Dimension Name].CurrentMember.Name, 5) = &#8216;My String Value&#8217;)}<br />
[/sql]</p>
<p><strong>To Check whether dimension value Equal a particular value </strong><br />
To check whether a dimension value Equal  a particular value, you need to add a filter condition as follows.<br />
[sql]<br />
{FILTER([My Dimension Group].[Dimension Name].[Dimension Name], [My Dimension Group].[Dimension Name].CurrentMember.Name = &#8216;My String Value Carolina&#8217;)}<br />
[/sql]</p>
<p><strong>To Check whether dimension value is NULL </strong><br />
To check whether a dimension value is NULL, you need to add a filter condition as follows.<br />
[sql]<br />
{FILTER([My Dimension Group].[Dimension Name].[Dimension Name], [Measures].[Mesure Name] = NULL)}<br />
[/sql]</p>
<p><strong>To Check whether dimension value is NOT NULL </strong><br />
To check whether a dimension value is NOT NULL, you need to add a filter condition as follows.<br />
[sql]<br />
NON EMPTY([My Dimension Group].[Dimension Name].[Dimension Name])<br />
[/sql]</p>
<p>Following are the examples of queries which uses above mentioned expressions.</p>
<p><strong>Query 1</strong><br />
[sql]</p>
<p>SELECT {[Measures].[Mesure Name]} ON COLUMNS,<br />
({FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Trim([My Dimension Group].[Dimension Name].CurrentMember.Name) = &#8221;)}) ON ROWS<br />
FROM [My Cube Name]</p>
<p>[/sql]</p>
<p><strong>Query 2</strong><br />
[sql]<br />
SELECT {[Measures].[Mesure Name]} ON COLUMNS,<br />
({FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Instr([My Dimension Group].[Dimension Name].CurrentMember.Name, &#8216;My String Value&#8217;) &gt; 0)}) ON ROWS<br />
FROM [My Cube Name]<br />
[/sql]</p>
<p><strong>Query 3</strong><br />
[sql]<br />
SELECT {[Measures].[Mesure Name]} ON COLUMNS,<br />
({FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Left([My Dimension Group].[Dimension Name].CurrentMember.Name, 5) = &#8216;My String Value&#8217;)}) ON ROWS<br />
FROM [My Cube Name]<br />
[/sql]</p>
<p><strong>Query 4</strong><br />
[sql]<br />
SELECT {[Measures].[Mesure Name]} ON COLUMNS,<br />
({FILTER([My Dimension Group].[Dimension Name].[Dimension Name], Right([My Dimension Group].[Dimension Name].CurrentMember.Name, 5) = &#8216;My String Value&#8217;)}) ON ROWS<br />
FROM [My Cube Name]<br />
[/sql]</p>
<p><strong>Query 5</strong><br />
[sql]<br />
SELECT {[Measures].[Mesure Name]} ON COLUMNS,<br />
({FILTER([My Dimension Group].[Dimension Name].[Dimension Name], [My Dimension Group].[Dimension Name].CurrentMember.Name = &#8216;My String Value Carolina&#8217;)}) ON ROWS<br />
FROM [My Cube Name]<br />
[/sql]</p>
<p><strong>Query 6</strong><br />
[sql]<br />
SELECT {[Measures].[Mesure Name]} ON COLUMNS,<br />
({FILTER([My Dimension Group].[Dimension Name].[Dimension Name], [Measures].[Mesure Name] = NULL)}) ON ROWS<br />
FROM [My Cube Name]<br />
[/sql]</p>
<p><strong>Query 7</strong><br />
[sql]<br />
SELECT {[Measures].[Mesure Name]} ON COLUMNS,<br />
NON EMPTY([My Dimension Group].[Dimension Name].[Dimension Name]) ON ROWS<br />
FROM [My Cube Name]<br />
[/sql]</p>
<p>That is for now 🙂</p>
<p><span style="color: #ff6600;"><strong>Conclusion</strong></span></p>
<p>I hope someone found this article useful. Please share me your valuable thoughts and comments. Your feedback is always welcomed.</p>
<p>Thanks in advance. Happy coding!</p>
<p>Kindest Regards<br />
<a href="https://plus.google.com/+sibeeshkv" target="_blank">Sibeesh Venu</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/filters-in-mdx-queries/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
