Learn SQL Server bi--application development step by step

Source: Internet
Author: User
Tags count

Then we last the "step-by-step Learning sqlserverbi--Multidimensional Database Building", now we have a multidimensional database, and there are already data, then quickly enter the topic of our programmers.

Today I want to develop two applications on this multidimensional database:

1. To count the transactions of each department on a per-day basis

2. Count the volume of each department and game on a per-day basis

First design a strongly typed DataSet, as shown in the following figure.

Statistics by department data set

Cross-statistical datasets by department and game

Design MDX statements, execute MDX at the data tier, and return to Cellset

/**////<summary>

///Statistics The transaction data for each department by day
///</summary>
///<param name= "Tradedatekey" > Date key value </param>
<returns></returns>
Public CellSet Count (int tradedatekey)
{
StringBuilder mdxbuilder = new S Tringbuilder ();
Mdxbuilder.append ("with member [measures].[ Total Orders Count] as ' SUM ([measures].[ Total Orders]);
Mdxbuilder.append ("member [measures].[ Total Amount Count] as ' SUM ([Measures]. [Total Amount]);
Mdxbuilder.append ("member [measures].[ Total money Count] as ' SUM ([measures].[ Total) ");
Mdxbuilder.append ("member [measures].[ Un Paid Cancel Amount Count] as ' SUM ([measures].[ Un Paid Cancel Amount]);
Mdxbuilder.append ("member [measures].[ Un Paid Cancel Money Count] as ' SUM ([measures].[ Un Paid Cancel Money] ");
Mdxbuilder.append ("member [measures].[ Paid Cancel Amount Count] as ' SUM ([measures].[ Paid Cancel Amount]);
Mdxbuilder.append ("member [measures].[ Paid Cancel Money Count] as ' SUM ([MeasurES]. [Paid Cancel money]);
Mdxbuilder.append ("Select {measures].[ Total Orders Count], [Measures]. [Total Amount Count], [Measures]. [Total Money Count], [Measures]. [Un Paid Cancel Amount Count], [Measures]. [Un Paid Cancel Money Count], [Measures]. [Paid Cancel Amount Count], [Measures]. [Paid Cancel money Count]} On COLUMNS, ");
Mdxbuilder.append ("{[department].[ Dep. Code Alternate Key]. Members} on ROWS ");
Mdxbuilder.append ("from [Data Center DW]");
Mdxbuilder.append ("WHERE" [time].[ TimeKey]. ["+tradedatekey+"]);

Return DBServer.AnalysisServer.ExecuteCellset (mdxbuilder.tostring ());
}

/**////<summary>

///Statistics The transaction data for each game's individual department by day
///</summary>
///<param name= "Tradedatekey" > Date key Values </param>
///<returns></returns>
Public CellSet Count (int tradedatekey,int departmentkey)
{
StringBuilder Mdxbuilder = new StringBuilder ();
Mdxbuilder.append ("with member [measures].[ Total Orders Count] as ' SUM ([measures].[ Total Orders]);
Mdxbuilder.append ("member [measures].[ Total Amount Count] as ' SUM ([measures].[ Total Amount]);
Mdxbuilder.append ("member [measures].[ Total $ Count] as ' SUM ([Measures]. [Total money]);
Mdxbuilder.append ("member [measures].[ Un Paid Cancel Amount Count] as ' SUM ([measures].[ Un Paid Cancel Amount]);
Mdxbuilder.append ("member [measures].[ Un Paid Cancel Money Count] as ' SUM ([measures].[ Un Paid Cancel Money] ");
Mdxbuilder.append ("member [measures].[ Paid Cancel Amount Count] as ' SUM ([measures].[ Paid Cancel Amount]);
Mdxbuilder.append ("member [measures].[ Paid Cancel MOney Count] as ' SUM ([measures].[ Paid Cancel money]);
Mdxbuilder.append ("Select {measures].[ Total Orders Count], [Measures]. [Total Amount Count], [Measures]. [Total Money Count], [Measures]. [Un Paid Cancel Amount Count], [Measures]. [Un Paid Cancel Money Count], [Measures]. [Paid Cancel Amount Count], [Measures]. [Paid Cancel money Count]} On COLUMNS, ");
Mdxbuilder.append ("{[game].[ Game Code Alternate Key]. Members} on ROWS ");
Mdxbuilder.append ("from [Data Center DW]");
Mdxbuilder.append ("WHERE" [time].[ TimeKey]. ["+ Tradedatekey +"],[department]. [Dim Department]. ["+departmentkey.tostring () +"]);

Return DBServer.AnalysisServer.ExecuteCellset (mdxbuilder.tostring ());
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.