.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Dynamic Dimension with Aggregate Values

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :Sql Server
Hi, I have an specific requirement to make the measure value as an dimension. Let me explain my problem in brief. I have a fact table with dimensions like Time, Products etc and having single fact table with two measures. I have to create a calculated measure which shows the average of Measure 1 (here used calculated measure because there are couple of other calculations involved). And other two calculated measures. when I drill down with Products dimension for Calculate measure 1, it shows the average value for each products. Now, I want this calculated measure values (includes Product dimesnion drill down) as a Dimension and based on this value, I need to show the value of other two measures. For example: when the dimension products is used for drill down the values displayed will be like this and in this I need CM1 to be another dimension Products CM1 CM2 CM3 P1 0.10% 20 1 P2 0.20% 40 2 P3 0.30% 80 3 P4 0.40% 70 4 P5 0.50% 30 5 P6 0.60% 110 6 P7 0.70% 120 7 P8 0.80% 130 8 P9 0.90% 86 9 P10 1.00% 65 10 when CM1 is used as a dimension it should show the value like this CM1 CM2 CM3 0.10% 20 1 0.20% 40 2 0.30% 80 3 0.40% 70 4 0.50% 30 5 0.60% 110 6 0.70% 120 7 0.80% 130 8 0.90% 86 9 1.00% 65 10 How can we create the dynamic dimension with the aggregated values? Any assistance will be greatly apprec

View Complete Post

More Related Resource Links

gridview help on each dynamic row solve this show values based on all columns

<asp:GridView style="Z-INDEX: 101; LEFT: 1px; POSITION: absolute; TOP: 183px" id="Gridview1" runat="server" Width="613px" Height="127px" ForeColor="Teal" Font-Size="12pt" Font-Names="Palatino Linotype" Font-Bold="True" Visible="False" BorderColor="Transparent" AutoGenerateColumns="false" CellSpacing="2" GridLines="None" OnRowCreated="Gridview1_RowCreated" SelectedIndex="5" ShowFooter="true" OnRowDataBound="Gridview1_RowDataBound"><Columns>  <asp:TemplateField HeaderText="ItemCode"><ItemTemplate> <asp:DropDownList id="DropDownList1" tabIndex=16 runat="server" AutoPostBack="True" DataValueField=" ItemCode " DataTextField=" ItemCode" ></asp:DropDownList></ItemTemplate></asp:TemplateField>  <asp:TemplateField HeaderText="ItemName"><ItemTemplate> <asp:DropDownList id="DropDownList2" tabIndex=16 runat="server" AutoPostBack="True" DataValueField="ItemName" DataTextField="ItemName" ></asp:DropDownList> </ItemTemplate> </asp:TemplateField>  <asp:TemplateField HeaderText="Category"&

Other group with VisualTotals and dynamic dimension

I All, I’m trying to create a query that dynamically display a dimension attribute on rows. I want display only first N member of that dimension attribute and aggregate the others in ‘Others’ member   (this query should be used in Reportig services and data displayed in both Crosstab and Pie Chart). So I’ve 2 parameters:   @TopN: Value: 5 @RowDimension:  Value: [Product].[Subcategory]   And the code look like this:   WITH SET [DynamicDimension] as strtoSet(@RowDimension + '.MEMBERS') MEMBER [Measures].[RowCaption] as strtoMember(@RowDimension).MEMBER_CAPTION   SET [TopItem] as TopCount(DynamicDimension,@TopN,[Measures].[Order Count]) SET [BottomItem] as {[DynamicDimension]} - {[TopItem]}   MEMBER [Product].[Subcategory].[Other ] as aggregate(BottomItem)   SELECT {[Measures].[Order Count]} ON COLUMNS , Non Empty {      [TopItem] ,[Product].[Subcategory].[Other]     } ON ROWS FROM [Adventure Works]   Unfortunately this solution doesn’t work when I change the value of parameter @RowDimension (ex with [Customer].[Customer Name]). This is because calculated member “ [Product].[Subcategory].[Other]” is related to Product dimension and is not possible parametrize the name of a member. Any suggestions?   The alternative solution that I&r

SSAS 2008 Dimension root values changes after incrementally loading the dimension with 'process_up

The Dimension root  members (below 'ALL') changes after incrementally loading the dimension with 'process_update'.  How do I prevent that from happening ? There was no changes to data of the underlying table of the dimension.   

How to Create an MDX Query Parameter to Select 30 Values from a Dimension?

Hi, I'm using SSRS 2005 to report on an SSAS cube that contains a Procedure dimension.  I don't need to use members of this dimension in my report, but rather need to select records (patients) where their chart has one or more of the codes.  I've researched this today and cannot locate the best approach.  Thus far, I've attempted to create an MDX query parameter as part of my dataset.  However, I don't know whether this is the correct approach, and how to structure the syntax so that only records with one or more procedures are included in the report?  If so, what is the proper MDX syntax for setting my Procedure code equal to the query parameter? Thanks, Sid

Dimension Usage for non key values


I have, for purposes of this question, have 3 tables.


The ERD is:

What I need is:

For each record in the DimIVRCompletion Count the number of records in the FactEventIVR table where the ActivityCode is equal to the EntranceCode and the count where the activitycode is equal to the Completion code, then divide the Entrance Count by the Completion Count to get a percentage of completion.


The following MDX is what I think should be the query.




Member [Measures].[CompletionCount] as


{[Dim IVR Completion Code].[Completion Code Key].[Completion Code Key].Members},

{([Dim IVR Completion Code].[Completion Code Key].CurrentMember)} *

{[Measures].[Fact Event IVR Count]})

Member [Measures].[EntranceCount] as 


{[Dim IVR Completion Code].[Entrance Activity Code Key].[Entrance Activity Co

Can we pass dimension values as parameters in MDX


Hi All,

I am doing something similar to basket analysis and I wrote an MDX to see the trend of purchases over time for a customer. How can I dynamically pass values of customer or product purchased into mdx? In below example how can I change [product].[category] value? Also, can we change the dimension also dynamically?


with member measures.x as

Dynamic dimension member filter


Is it possible to set a dimension data rule for a role that will filter dimension members dynamically such that only members relating to at least one fact record will be shown?   In particular, the rule should be applied after all other filters on the fact data for the user have been taken into account.

This situation is there is a single client dimension but users should not be able to see the client information (e.g. name, address) unless it is related to a fact that the user has access to.




I want to use the values executed by a dynamic sql in a view. Can this be possible? Can you please l

Dynamic SQL Stored Proc:

        create procedure dbo.USP_USR_GETATTRIBUTEVALUE
                @AttributeName nvarchar(200),
                @ID uniqueidentifier,
                @AttributeValue nvarchar(200) output
                Declare @ATTRIBUTEVIEWNAME nvarchar(200)
                Declare @sql nvarchar(4000)

                set @ATTRIBUTEVIEWNAME = (select 'V_QUERY_ATTRIBUTE'+ convert(varchar(50),REPLACE(AC.ID,'-','')) from ATTRIBUTECATEGORY AC where AC.NAME=@AttributeName)


Dynamic Sql depending on parameter values



I have only just started to use Reporting Servcies and would like to know is there any way of putting IF statments into the SQL statment depending on the value of a selected parameter.

="select  code, cid, name + '(' + code + ')' as ShopName, qty, val, salesdate  from shops" & 
" inner join sal_sumdaily on code = shopcode inner join calendar on salesdate between weekstart and weekend" &
" where trading = 0 and shopclosed = 0 and cid = " & Parameters!RP_CID.Value & "" &
" and l4l = " & Parameters!RP_L4L.Value & "" &
" and newarea = " & Parameters!RP_Area.Value & "" &
" order by code"

What I would like to do is when "Parameter!RP_Area.value" = 99 then miss that part of the sql statment out, something like this.

="select  code, cid, name + '(' + code + ')' as ShopName, qty, val, salesdate  from shops" & 
" inner join sal_sumdaily on code = shopcode inner join calendar on salesdate between weekstart and weekend" &
" where trading = 0 and shopclosed = 0 and cid = " & Parameters!RP_CID.Value & "" &
" and l4l = " & Parameters!

Compare the values of a measure with reference to a time dimension


Hi experts, i am a novice on Analysis Services and i have this necessity:

I want to create a calculated member that compare the values of a dimension with reference to a time dimension.

Example :

Sales Year 2009   Sales year 2010   %Var

I have found this model of calc below but i not know well Analysis Services.

How can i implement this function? My time dimension named [Tempo].[Anno].[Anno] and my measure named [Measures].[Importo Neg]


// Test for current coordinate being on (All) member.



[<<Target Dimension>>].[<<Target Hierarchy>>].CurrentMember.

Dynamic Headers using an SSAS Parent Child Dimension



 We are trying to build some finanical reports (Balance Sheet, Income Statement, etc) in reporting services using Analysis Services as a data source.  The problem we are running into is more of a formatting issue around the use of custom headers.  We want to have the ability to do the following:

Interest Income (as a header)



Funds sold

Total Interest Income (rollup of children above)

Interest Expense (as a header)



Total Interest Expense (rollup of children above)

Provision for loan losses (single line item, no group needed)

Getting the parent to appear after the child is pretty simple by using the hierarchize function.  The problem is getting the parent as a header to appear.  The crux is that we only want to use certain levels (not every single level) in the parent child hierarchy for doing a header. For example, above, Interest Income and Interest Expese would have a header, whereas Provision for loan losses would not.

This is pretty common formatting features for financial reports, plus its very common to use a parent child for Chart of Accounts, thus somebody has had to have run into this in the past.




Problem in displaying values for foreign keys in Dynamic data asp.net web app


I have the following tables in my database which are as given under:


Table 2: CREATE TABLE [dbo].[PromotionCodes]( [PromotionCode] nchar NOT NULL, [CustomerPromotionDiscountID] [int] NOT NULL, [EmployeePromotionDiscountID] [int] NOT NULL, [IsActive] [bit] NOT NULL, CONSTRAINT [PK_PromotionCodes_1] PRIMARY KEY CLUSTERED ( [PromotionCode] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]

There is a foreign key relationship between columns (1) PromotionID of table PromotionDiscountValues and CustomerPromotionDiscountID of table PromotionCodes and (2) PromotionID of table PromotionDiscountValues and EmployeePromotionDiscountID of table PromotionCodes

When i browse the PromotionCodes table in the dynamic data listing, the following columns get displayed:

  1. PromotionCode

  2. IsActive

  3. Prom

Segregating Measure values based on the dimension value into separate columns.


Hi Hopefully you can help me with another problem I'm having.  I'm trying to design a regular SSRS report using a cube as data source here is where I run into difficulties.  This is a financial type report so it has attributes such as Actuals, Forecast,Plan etc.  These attributes reside in a cube in a dimension called "PROCESS".  The measures is of course dollars.  So what I need is to somehow segregate dollars for actuals into one column forecast into another etc etc in my query designer so my dataset has 3-4 distinct dollar columns on which I can build my report. I thought I could accomplish it by using a calculated member functionality but I can't find anything there that will let me filter the values by "PROCESS" dimension.  I've also tried to create separate datasets filtering dollars the way I need them in each however report will not let me have fields that belong to two different datasets.  Any thoughts on how to solve this issue.  Hopefully using GUI instead of MDX editor. 


Parsing Dynamic Activity Argument Default Values


Is it possibly to access the default value of a dynamic activity's argument through the API? I would like to do this outside of the scope of execution.

So far I've attempted to load the XAML as a DynamicActivity and access the individual DynamicActivityProperty types. In a DynamicActivityProperty, there is a Value property, but it returns a type of InArgument with actual type of the argument set as a generic. I would like to get the actual value of the InArgument, rather than InArgument<T>. I would assume this would be the actual default value of my argument.

The code I have so far looks something like this:

      System.Activities.Activity activity = null;
      DynamicActivity dynActivity = null;

      // Get bytes from string .xaml
      using (Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(xamlString)))
        activity = ActivityXamlServices.Load(stream);

      dynActivity = activity as DynamicActivity;

      // Iterate through workflow arguments
      foreach (Dy

Get primary key values from insert page and route to details page in a Dynamic Data Domain Service A


I finally figured out how to retrieve primary key values from the insert page template that are inserted via defaults in a SQL Server database. I wanted to get the keys so that I could route the user from the insert page template to the details page template (regardless of whether it’s a custom route or not). There are a number of scenarios where separate insert and details pages are desirable, and routing from the insert page back to the list page is not desirable as Dynamic Data does out of the box. Since I could not find an answer to this problem anywhere with significant effort, I decided I would document it for others, I hope you find it useful - it turns out that it's quite simple under 10 lines of code. I also applied the same idea to a Dynamic Data Entities application which works exactly the same except for two minor changes, I have documented it below as well.

For starters, as is documented plenty elsewhere but bears repeating here, you must first annotate your Entity Data Model with ScaffoldColumn = false for identity columns and guids that get assigned with newid() in thedatabase. This tells Dynamic Data not to attempt to pass a null value from the page through to

Display NULL value for all the dimension for a particular measure at the Aggregate(All) Level.


Hello All,

Please help me on this:

I have to display a measure value for all the dimensions as NULL at the aggregate/top/All level. For all the other dimensional levels, this measure value should be displayed. I used the following MDX, but it will hide the measure value for all the other dimensions(because while drilling through the other dimension, this condition will be satisfied by default):

SCOPE([abc].[abc].[abc].members, [MEASURES].[measure1]);      

 this = NULL;      




Userdefined aggregate function erroring out when all values are null


HI, I have a aggregate function that calculates median in all cases excet if every value that is being passed in is null and I cant seem on how to fix it. I beleive it has to do with either the read or write methods below is the code that I am using and the error. Any help on this would be greatly appreciated. Thanks in advane.







ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend