Showing posts with label calculated. Show all posts
Showing posts with label calculated. Show all posts

Friday, March 23, 2012

Saving Data and retrieving it from the database

Heres my requirement from a financial analysis im doing...

I have just calculated an industry averages on financial ratios...Now i wanna upload this industry average to the system...so that I can compare it to the individual companies' averages after calculating a particular company's average; meaning i wanna be able to call the industry average of a particular ratio (eg Current Ratio) after calculating a company's corresponding ratio...Is there a code fragment i can use for this ??

Thanks in advance...

Adam

Hi,

From your description, it seems that you are going to retrieve the industry averages which you stored in database after calculating particular company's averages, right?

I think the code should be based on the data structure. I don't know how do you handle with your data storage in your project? Does each company's average data stored in a table? Where does the industry average data comes from? It comes from manually calculating? If so, what you should do is just save the data into a single data table, when you are going to calculate each company's average, retrieve the data from your database and save it in a seesion or viewstate to avoid reading the value from database frequently.

Above is just the general idea for your question, as for detail code, it depends on what kinds of way you are going to use, SqlDataReader, Dataset and etc… But the usage of this kinds of data accessing technique can be found at the following address.
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/default.aspx

Thanks.

sql

Wednesday, March 7, 2012

Sanity Check: Measure Expression nearly always better than Calculated Measure?

Hey All --

From what I've read, Measure Expressions are generally superior to Calculated Measures because we can actually aggregate them. Most of the examples of Measure Expressions I've seen are something along the lines of [Measures].[Sales] / [Measures].[Sales Cost]...Both values are part of various measure groups.

I assume that even if I 'hard code" a value as in the following example my performance is STILL going to be much better in a measure expression (assuming we take advantage of aggs) than doing the same thing in a calculated measure:

[Measures].[Sales SubTotal] * 1.08 //Sales Tax)

So, I guess the question I'm asking is: Must a "valid" measure expression include ONLY measures and operators, or can it include any hard coded constant value I want to stick in, as well...And if the latter situation is "OK", we still get all of our perf benefits, etc.

Thanks!

The best thing to do would be to give it a shot with both approaches and see which works best for you. Look at both query response time and processing time impacts.

The SSAS 2005 Performance Guide suggests this is an optimal solution when working with data from multiple measure groups ... which is the case you identify above. Again, try it and see.

The easiest way to compare the two would be to go ahead and create the Measure Expression, process your cube, execute an MDX query to return data from the measure with the defined measure expression. Then, recreate the calculation in a WITH MEMBER clause of another MDX statement and compare its execution time to the original.

Good Luck,
Bryan