Showing posts with label items. Show all posts
Showing posts with label items. Show all posts

Thursday, February 16, 2012

Calculation between two rows

Hi,
I have a table and data set to populate it. I need to calculate
difference between two rows (lets say the number of items below) and
want to show the difference on another column on each row as below.
Does anyone know how to do that?
Table
Name #Items Date Difference
Bla Bla 60 05-06-2006 -40
Bla Bla 100 05-06-2006 20
Bla Bla 80 04-06-2006 0
Regards,
Alp Eren YILMAZAlp Eren schreef:
> Hi,
> I have a table and data set to populate it. I need to calculate
> difference between two rows (lets say the number of items below) and
> want to show the difference on another column on each row as below.
> Does anyone know how to do that?
> Table
> Name #Items Date Difference
> Bla Bla 60 05-06-2006 -40
> Bla Bla 100 05-06-2006 20
> Bla Bla 80 04-06-2006 0
> Regards,
>
> Alp Eren YILMAZ
Alp,
Something like currentmember-nextmember.......
Ronald|||On the Difference column's textbox right click and click on Expressions and
type the folliwing
=Fields!Item.Value - Previous(Fields!Item.Value)
This will give you the desired result.
Sum.
"Alp Eren" wrote:
> Hi,
> I have a table and data set to populate it. I need to calculate
> difference between two rows (lets say the number of items below) and
> want to show the difference on another column on each row as below.
> Does anyone know how to do that?
> Table
> Name #Items Date Difference
> Bla Bla 60 05-06-2006 -40
> Bla Bla 100 05-06-2006 20
> Bla Bla 80 04-06-2006 0
> Regards,
>
> Alp Eren YILMAZ
>|||Hi,
Thanks for the answers, a couple of tips
1- Change the sort order for the table data so you can use Previous
2- To reach the previous row data use Previous(..) function
= Previous( Fields!ColXXX.Value)-Fields!ColXXX.Value
MSDN Reference: http://msdn2.microsoft.com/en-us/ms156372(SQL.90).aspx
3- For the first row, avoid computation with iif and RowNumber(..)
check
Regards,
Alp Eren YILMAZ

Calculation based on total at Table footer (eg. % of report total)

Hi!
I have data on a report where I am subtotalling by Items on an invoice. So,
my subtotal has the sum of all the invoices for that item.
I also want to do a calculation that will calculate for each item (that is
summarized) % of total sale for all items. Presently, my totals for all items
are in the Table Footer.
Item Amount Percent of Total
A 10 (subtotal) 10/15 =67%(ie divided by report
total)
B 5 (subtotal) 5/15 =33%
Report Total = 15
How do I do this?
Thanks
Ranjit CharlesHi,
You need to have a report variable which stores the grand total already or a
select statement which stores the grand total. Then you can use this variable
to find out the percentage. You can have a dataset created for this select
alone which will find out the grand total and use the dataset for percentage.
Regards
Amarnath
"Ranjit Charles" wrote:
> Hi!
> I have data on a report where I am subtotalling by Items on an invoice. So,
> my subtotal has the sum of all the invoices for that item.
> I also want to do a calculation that will calculate for each item (that is
> summarized) % of total sale for all items. Presently, my totals for all items
> are in the Table Footer.
> Item Amount Percent of Total
> A 10 (subtotal) 10/15 =67%(ie divided by report
> total)
> B 5 (subtotal) 5/15 =33%
> Report Total = 15
> How do I do this?
> Thanks
> Ranjit Charles|||Or you can sum the total amount and put it in to a new value field for the
select statement...
e.g. select *, (select sum() ... from ...) "GrandTotal" from ...
which obviously means you calculate the total for every line but SQL is
pretty efficient.
Craig
"Amarnath" <Amarnath@.discussions.microsoft.com> wrote in message
news:4977EB5C-C4A7-4109-B61E-F3D9B059DE28@.microsoft.com...
> Hi,
> You need to have a report variable which stores the grand total already or
> a
> select statement which stores the grand total. Then you can use this
> variable
> to find out the percentage. You can have a dataset created for this select
> alone which will find out the grand total and use the dataset for
> percentage.
> Regards
> Amarnath
>
> "Ranjit Charles" wrote:
>> Hi!
>> I have data on a report where I am subtotalling by Items on an invoice.
>> So,
>> my subtotal has the sum of all the invoices for that item.
>> I also want to do a calculation that will calculate for each item (that
>> is
>> summarized) % of total sale for all items. Presently, my totals for all
>> items
>> are in the Table Footer.
>> Item Amount Percent of Total
>> A 10 (subtotal) 10/15 =67%(ie divided by report
>> total)
>> B 5 (subtotal) 5/15 =33%
>> Report Total = 15
>> How do I do this?
>> Thanks
>> Ranjit Charles

Friday, February 10, 2012

Calculated members are unbelievably slow

In general. Need help what are the top items I must check? My client is Excel Pivot table

I have one cal. member [NAV] from one fact table I am getting POSN TOTL CURR NAV BAL PTFC and OWNSHP PRCNTG

cal. mem [NAV] formula is below

Iif(([Investment].CurrentMember.Level.Name = "Investment Cd" or

[Investment].CurrentMember.Level.Name="Investment Type Cd") and

([Investor].CurrentMember.Level.Name="Investor Type Cd" or

[Investor].CurrentMember.Level.Name="Investor Cd" or

[Investor].CurrentMember.Level.Name="Investor Desc") ,

[Measures].[POSN TOTL CURR NAV BAL PTFC] * [Measures].[OWNSHP PRCNTG] ,

Iif([Investment].CurrentMember.Level.Name="Investment Cd" or

[Investment].CurrentMember.Level.Name="Investment Type Cd" ,

[Measures].[POSN TOTL CURR NAV BAL PTFC] ,

Iif(([Investor].CurrentMember.Level.Name="Investor Type Cd" or

[Investor].CurrentMember.Level.Name="Investor Cd" or

[Investor].CurrentMember.Level.Name="Investor Desc") ,

[Measures].[POSN TOTL CURR NAV BAL FUND] ,

Sum({[Investor].AllMembers}, [Measures].[POSN TOTL CURR NAV BAL FUND]))))

and hand full of simple calculations like this from different fact table

[Measures].[EQ UP 5P]/[Measures].[NAV]

Thank you - Ashok

Couple of suggestions:

1. Get rid of all IIF's and replace them with SCOPE as explained here: http://www.sqljunkies.com/WebLog/mosha/archive/2007/01/28/iif_performance.aspx

2. Revisit whether Sum({[Investor].AllMembers}, [Measures].[POSN TOTL CURR NAV BAL FUND])) is even correct. I think it isn't. It tries to sum up members from all levels of Investor dimension. This cannot be right. Also, it is going to be constant regardless of the current coordinate in Investor dimension, even though the rest of your expression carefully looks at the current coordinate in Investor.

|||

Thanks Mosha,

Because I have more then one IIF and I am new to MDX can I replace my NAV MDX with this ?

SCOPE (([Investment].CurrentMember.Level.Name = "Investment Cd" or [Investment].CurrentMember.Level.Name="Investment Type Cd")
and ([Investor].CurrentMember.Level.Name="Investor Type Cd" or [Investor].CurrentMember.Level.Name="Investor Cd"
or [Investor].CurrentMember.Level.Name="Investor Desc"));
This = [Measures].[POSN TOTL CURR NAV BAL PTFC] * [Measures].[OWNSHP PRCNTG];
SCOPE ([Investment].CurrentMember.Level.Name="Investment Cd" or [Investment].CurrentMember.Level.Name="Investment Type Cd");
This = [Measures].[POSN TOTL CURR NAV BAL PTFC];
SCOPE ([Investor].CurrentMember.Level.Name="Investor Type Cd" or [Investor].CurrentMember.Level.Name="Investor Cd" or
[Investor].CurrentMember.Level.Name="Investor Desc"));
This = [Measures].[POSN TOTL CURR NAV BAL FUND];
SCOPE ([Investor].AllMembers)
This = [Measures].[POSN TOTL CURR NAV BAL FUND];
END SCOPE;

Thank you - Ashok

I just tried this and I am getting syntax error

CREATE MEMBER CURRENTCUBE.[MEASURES].[NAV]

AS SCOPE ([Investor].AllMembers);

This = [Measures].[POSN TOTL CURR NAV BAL PTFC] * [Measures].[OWNSHP PRCNTG];

END SCOPE;,

VISIBLE = 1 ;

|||

Looks like you are still learning the syntax of MDX scripts. Here are two resources which have examples of how to convert IIF to SCOPE:

1. AS2005 Performance Guide http://download.microsoft.com/download/8/5/e/85eea4fa-b3bb-4426-97d0-7f7151b2011c/SSAS2005PerfGuide.doc. (look for the MDX optimization section)

2. This blog also has an example: http://www.sqljunkies.com/WebLog/mosha/archive/2006/11/05/non_empty_behavior.aspx