Showing posts with label dimension. Show all posts
Showing posts with label dimension. Show all posts

Thursday, March 29, 2012

Calculated Member help

Hi, I have a calculated member that computes the Sales per week for any given level. I am using a time dimensiona and a sales dimension. The time dimension has these levels: Year, Quarter, Month, and Weeks. I am using this formula

[Measures].[Sales]/Descendants([TIME_WEEK_DIM],[TIME_WEEK_DIM].[Time Week Desc]).count

The problem with this is that it works only if the user select a single time member. I am using Excel as frontend and I fixed the pivot table in such a way that Sales is on the column, and Store is on the Rows. The time dimension is on the top serving as filter (Page axis). Because you can choose multiple dimension member in the dropdown boxes of any dimension in Excel, I am having trouble making it work in these scenario. It only works if you select one time member at a time. Please help.I don't fully understand what you are trying to do, but since the database server is returning a simple dataset to your Excel pivot table, the problem would appear to be with the pivot table and not the query or table you are using. When you filter the pivot table you are fiiltering its stored snapshot of the query results. It does not pass the parameters back to the database server.

blindman|||Hi, thnks so much for the reply. Anyway, to make it clear to you:

I'm using an Analysis Service Cube as my backend and Excel Pivot table as my frontend.

I have two dimension in my cube: 1. Time(Yr, Qtr, Month, Week) and 2. Store

I have two measures: 1. Sales and 2. Sales per week (this measure is a calculated member

The formula I use to make the Sales per week measure is:
[Measures].[Sales]/Descendants([TIME_WEEK_DIM],[TIME_WEEK_DIM].[Time Week Desc]).count

Here's my setup in Excel: The sales is broken down by store and the time is on top acting as a filter

Time: 2003

Store Sales Sales/Week
Store1 100 25
Store2 200 12

My problem occurs evrytime the user selects more than one Time value to filter on (like all Jan AND Feb data). It works only if one time value is selected at a time. When user chooses more than 1 time value, the Sales/Week data appears as: #Num!|||Sorry smb, but I don't have experience with data cubes syntax. Hopefully now that your post is at the top of list someone else will check it out and give you an answer!

blindman|||Thnks anyway blindman :)

Sunday, March 25, 2012

Calculated Measure And Drill Through

I am getting the error below in Proclarity:

"Error Accessing Drill To Detail Information

xxxxxxx in dimension Measures is a calculated member."


Can AS2005 support drill through from a calculated member, if not is there a work around?

Thanks

The answer is pretty easy but you might not like it: The drillthough is not supported on the calculated measures or calculated members.

Not sure what would you expect from the drillthoguh into calculated measure or member. Calulated member could be totally unrelated to the facts in your cube. How would you drillthorouh into that? You can definitely can come up with simple case of calc measure being sum of two measures in the same measure group, but that is very narrow and not practical case.

Edward Melomed.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

Thursday, March 22, 2012

Calculated field in a Cube

Hi!

I need your help!..

I need aid to obtain a value in a calculated field, I am using cube with dimension in the date.

The idea is that as of a specific month the accumulated sum of a value is obtained in a calculated field, starting off from the month of January of he himself year that the specified month previously.

For example:

If I indicate the month of April, the sum of the value had to be:

Total = Value January + Value February + Value March + Abril Value

The previous months are of he himself year that the month of April and does not have to take values from the previous year.

If it indicated the month of December it must add the 12 months of the year to which that month corresponds I hope somebody can help me.

From already, thank you very much!

Assuming that your date dimension has its levels tagged with the appropriate time types, then you could simply use YTD(), like:

Sum(YTD([Date].CurrentMember), [Measures].[MyValue])

If the date levels aren't appropriately tagged, PeriodsToDate() is a more general function, like:

Sum(PeriodsToDate([Date].[Year].[Year], [Date].CurrentMember), [Measures].[MyValue])

calculated DistinctCount over two levels of "incomplete" weeks

Hello all,
I have a cube on as2005 where my Time dimension has 5 levels(year, month, quarter, week, day) and a measure that is a distinct count of customers (I also have a customer dimension, with 1 level: customer)

In my time dim, I have "incomplete" weeks, for example the week 32 exist on both august and september months, 5 days of the week in august and 2 days in september.
So at week level I get the distinct customers for that week, for example:
month | week | # distinct customers
AUG | 32 | 15
SEPT | 32 | 20

but, since the week is the same, i want to get the distinct customers for the whole week, and put it on the last month where that week appears, in the example let's say that for week 32 there are 18 different customers, I want a 18 on SEPT.

month | week | # distinct customers
AUG | 32 | NULL
SEPT | 32 | 18

Someone know how can I achieve this?
Thanks!I've found the way to do this, I hope this helps the community!

Aggregate
(
UNION([DM Time].[Hierarchy].CurrentMember.PrevMember.Children,[DM Time].[Hierarchy].CurrentMember.Children)
,[Measures].[# Customers]
)

only for the scope of the week.

Calculated Dimension Member Problem

Hi,

I have a problem that I think I can solve by creating a calculated member in my time dimension, but I am struggling to get it to work.

My time dimension has a hierarchy of Year, Month, Week. The years go from 2002 to 2007, with an additional 'Pre 2002' year (having one month and one week). What I need to do is create an additional year which is the combination of 2002 and 'Pre 2002', which will then be called 'Pre 2003'. I have tried the following:

Code Snippet

CREATE MEMBER CURRENTCUBE.[Time].[Time].[All].[Pre 2003]

AS [Time].[Time].[Year].&[2002] + [Time].[Time].[Year].&[2001], -- (2001 is my name for the pre 2002 member)

VISIBLE = 1 ;

This builds ok, but when I browse the dimension, or use it in Excel 2003, the calculated member is nowhere to be seen.

Any ideas?

Dave

Your formula should be OK. An equivalent calc member for Adventure Works is the following.

create member currentcube.[Date].[Fiscal].[All Periods].[Pre 2004] as

[Date].[Fiscal].[Fiscal Year].&[2002] + [Date].[Fiscal].[Fiscal Year].&[2003];

In order to see your new calculated member you need to make sure you have deployed the changed calculation script to the server. When your said "this builds ok", it gave me an idea that you work in project mode (there is also possibility to work explicitly connected to the server). In the project mode the change you made is related only to the local files on your drive. When you use Build menu item it means that a validation has happened and a deployment script has been created but it does not mean the server already knows your changes. You need to use Deploy menu item in order Visual Studio to send your changes to the server. After that you should see your calculated member in the *new* browser window. If you already had it open you need to select Reconnect button for the change to be visible in the browser window.

In the server online mode (when you work directly with the server) you would just hit Save button and reconnect the browser.

Also, make sure you browse your Time hierarchy of Time dimension. A dimension can have more than one hierarchy. Similarly in Adventure Works i see the member above only when i browse Fiscal hierarchy of the Date dimension but Calendar hierarchy does not have the member.

|||

Andrew,

I am definitely deploying the changes to the server, as any other calculated measures appear correctly.

I have tried using the Adventure Work example you gave, and I have the same problem. In the dimension browser the new period is nowhere to be seen.

|||

Ok,

I can now see the calculated member. I was looking in the dimension browser instead of the cube browser!! Now I have another problem. I am connecting to the cube from Excel 2003, and when I drag in the hierarchy I cannot see the new member. In Excel 2007 there is a pivot table property "show calculated members from OLAP server" When I set this I can see the member fine. However, I need to use Excel 2003 for this project. I have found a pivot table property "ViewCalculatedMembers" which I have set to true using VBA. However, the member still does not appear.

Any ideas?

Calculated Dimension Member destoys date-hierarchy structure

Hi, I have a problem if I add a Calculated Dimension Member to a Date Hierarchy,

first I thought - I would set attribute relationship of my date-dimension not properly,

but then I tried to apply this to AW-DataBase.

Here's a script of creating Calculated Member in AW (Date.Calendar):

CREATE MEMBER CURRENTCUBE.[Date].[Calendar].[All Periods].[DateCalcMember_CopyOf2004]
AS [Date].[Calendar].[Calendar Year].&[2004],
VISIBLE = 1 ;

After adding it, try to expand the years-nodes in browser: you won't find any semesters behind,

except CY2001 - he got all semesters of other as childs.

It is possible to configure this behaviour somewhere or it is a bug of OWC 11 PivotTable that is used

in Cube Browser?

Thank you in advanced for your answers.

Regards, Mastroyani

Hi Mastroyani. Your problem definition is not 100% clear, so I made an assumption. The assumption is the problem definition which is, "after adding the calculated member and browsing the dimension in the cube browser the only member which shows the half-year members ([H1 CY 2002], [H2 CY 2002], etc.) is the [CY 2001] member." You can isolate where the problem lies by using another tool such as the SQL Server 2005 Manager to issue a separate MDX query outside onf the Cube Browser. Below is an MDX query using your same definition for [DateCalcMember_CopyOf2004]. You can see from the results that the member [CY 2004] shows it's own half-year children. Perhaps you are seeing an error with the cube browser?

Hope this helps - Paul Goldy

WITH MEMBER [Date].[Calendar].[All Periods].[DateCalcMember_CopyOf2004]
AS '[Date].[Calendar].[Calendar Year].&[2004]'

SELECT
{[Measures].[Internet Sales Amount]} ON COLUMNS
,{[Date].[Calendar].[Calendar Year].&[2004]
,[Date].[Calendar].[Calendar Year].&[2004].Children
,[Date].[Calendar].[All Periods].[DateCalcMember_CopyOf2004]} ON ROWS
FROM [Adventure Works]

===== Results

Internet Sales Amount
CY 2004 $9,770,899.74
H1 CY 2004 $9,720,059.11
H2 CY 2004 $50,840.63
DateCalcMember_CopyOf2004 $9,770,899.74

|||Hi, I have exactly the same problem. Have anybody figured out the problem?

thanks
Hank

Calculated Average w/o a dimension specified

OK, Here's another one...

I want to create a calculated member that compares the current member to the average of the other members at the same level the member is in.

The catch is that I want this to be a calculated member in the cube that works regardless of what dimensions/hierarchies the data is broken down with.

The MDX below shows what I want to do except that it requires the SERIAL_NUM hierarchy to be hardcoded:

Code Snippet

WITH MEMBER [Avg] AS AVG([SERIAL_NUM].Siblings, Measures.[Count Of Failures])

SELECT NON EMPTY { [Measures].[Count of Failures] , [Avg]} ON COLUMNS, NON EMPTY { ([Vehicle Info].[SERIAL_NUM].[SERIAL_NUM].ALLMEMBERS ) } ...

The end result should be something like this:

SERIAL_NUM Count Of Failures Avg 423343 10 30 432434 20 30 123123 60 30

But I again, I don't know what dimensions hierarchies will be used later on, I just want all the values the user is currently looking at be included in the calculated measure. If they replaced SERIAL_NUM with MODEL as the dimension, I want it to perform the same calculated on the data provided from that query.

I tried something like MEASURES.SIBLINGS, MEASURES.MEMBERS, etc, but they returned only the current value, as it appears to be the lowest hierarchy so it has no siblings.

(The end result, BTW, is not the average, but the number of std dev's a certain value is from the average of the other values, essentially a dynamic outlyer flag. So it'll be (Count of Failures - Avg (siblings)) / StdDev (siblings), I'm just trying to keep things simple)

Geof

Well, I thought I had it for a moment...

The function I tried was Axis(0)...

Code Snippet

IIF(MEASURES.[Count of Failures] = Null, Null,

(MEASURES.[Count of Failures] - AVG(AXIS(0), MEASURES.[Count of Failures])) / StDev(Axis(0), MEASURES.[Count of Failures])

)

Seems like it should work, but it's not giving the correct data. The data varies according to where I've drilled down to, and isn't consistent. Perhaps I could filter the Axis(0) set somehow? It looks like it's including the subtotal members from each dimension (the more dimensions I add, the more rows are reported in the Axis(0) set)

|||

You might be able to use a combination of generate and/or filter to filter out the dimension in MDX, but given that you don't really know how many dimensions could be stacked on the axis, I can't envisage how it would really work.

The other problem with Axis(0) is that it refers to the column axis, if a user flips the query around to put the dimension on the rows you would need to use Axis(1), but there is not easy way to tell what the user is doing.

How many dimensions would you want to use with this calculation? Would it be feasable to create a calculated measure for each applicable dimension? This might also lead to some interesting analysis opportunities.

|||

The biggest problem I've got with Axis(0) is that it include the subtotals and grand totals as simply another row, and since I don't have a fixed dimension to work with, I've been unable to filter them out of the set.

The Rows/Columns issue you mention is a problem, but not the end of the world. The users doing the queries will be reasonably experienced, just not enough to craft their own MDX. I can warn them about that scenario (if the other problem can be fixed)

How many dimensions? So far 4 is the largest number for the basic queries currently planned, though when people start wanting more estoteric comparisons, it will increase. So that could be feasible.

|||This sort of filtering might be something that is best suited to a .Net stored proc. I think you might need to iterate over the set a couple of times to figure out what you are looking at and which members are at the lowest level on the axis. The best set of stored proc samples I know if is at a project which I contribute to at www.codeplex.com/asstoredprocedures

Sunday, March 11, 2012

Caching with Dynamic Security

I defined one role in my AS database with dynamic security for each dimension. I am accessing the AS database in an ASP.NET web application which runs under a domain user and uses Form Authentication. Therefore I always connect to the AS database under the same domain user even though security should be based on the user logged into the web application. When I run a MDX query, I pass along the web user's security info as part of the connectionstring and uses dynamic security to get the AllowedSet for each dimension. However, I notice my user defined function is ran only on the first time I run a query, meaning the dimension security is cached based on the domain user in the connection string and not the web user. Sorry if this sounds confusing but I can clarify a bit more if needed. My question boils down to: Is there a way to tell AS database to cache result base on the CustomData property of the connectionstring?

The answer is YES - AS is smart enough to recognize that different values of CustomData were used even though the real identity on the connection is the same. Since the main purpose of CustomData was for custom authentication - it is treated the same as different users. Same is true w.r.t. Roles and UserId properties.

HTH,

Mosha (http://www.mosha.com/msolap)

|||

Mosha,

As always, you are right and thanks for the help. I did a little more testing after my post and realized AS is caching the result base on the CustomData property. Thanks!

Thursday, February 16, 2012

By Account Aggregation Function

Hello All,

I have tried creating a sample SSAS Project, using the AdventureWorksDW DB.

I have created an account parent-child dimension using an account dimension type.

I'm using the measure Amount from the FactFinance table, and used the ByAccount aggregateFunction property for that measure.

The problem is, when deploying that project I get the following error:

Aggregation function NONE specified for mapping account type Statistical is not supported for ByAccount semiadditive measure.

The Statistical account type aggregation function is set by the business intelligence wizard to None. I see no way to change it.

Does anyone see what's the problem here?

Hi,

The aggregation functions can be changed by selecting Database -> Edit Database in the AS project in BIDS.

-Morten