Showing posts with label product. Show all posts
Showing posts with label product. Show all posts

Friday, February 24, 2012

Calculations

Hi,

I have a cube like that:

Account Dimension vs Product Dimension

Sell Income | Quantity | Unit Price

Computers 210 7 30

Computer A 20 2 10

Computer B 100 5 20

Sell Income = Quantity * Unit Price

The cube always aggregate first and after it calculate, because of that the total get wrong, Sell Income of Computers give me $210 and the correct value is $120. I tried put that formula in the dimension custom roll up, in dimension unary operation, in a calculated member but always give me the wrong value.

The only solution is create a script command in the cube calculation like this:

Scope(leaves(account), leaves(product))

[Account].[Sell Income] = [Account].[Quantity] * [Account].[Unit Price];

End Scope;

But that way I have performance problem. Any ideia?

Regards,

Handerson

You could try adding a "Sell Income" Named Calculation to the fact table in the Data Source View (DSV), like:

Quantity * Unit Price

Then create a "Sell Income" measure, with "sum" aggregation function, on this new fact field.

Sunday, February 19, 2012

calculation question

Hi,

how can write MDX in calculation for this case I highlighted in red?

product Sale contribution

-

a | 30.00 30/80 = 0.375

b | 50.00 50/80 =0.625

total | 80.00

-

[measures].[sale]/ sum ([measures].[sale] in current level ) ?

Thanks in advance.

Dear Friend,

try this and tell me if works:

Code Snippet

WITH
SET [InterestingProduts] AS
'{[Product].&[2],
[Product].&[1]}'

MEMBER [Product].[TotalOfInterestingProducts] AS
'SUM([InterestingProduts])'
MEMBER [MEASURES].[Percentage] AS
'[Measures].[Sales]/([Measures].[Sales],[Product].[TotalOfInterestingProducts])',

SOLVE_ORDER=5

SELECT {[Measures].[Sales],[MEASURES].[Percentage]} ON COLUMNS,
{[Product].members,[Product].[TotalOfInterestingProducts]} ON ROWS
FROM [YourCube]

Is more completed... but try if works!

regards!

|||

Hi PedroCGD,

Thanks for your code Smile

It works perfectly.

And I have another challenge that if I want to view percentage in each level (please see the example below) then how should I define for this scnario?

Currently, it only works in product a / b level. If I drill down and see the percentage then it calculates like this below:

i.g. product a-1 : 10/100 --> want to correct 10/30

product a-2: 20/ 100 > want to correct 20/30

percentage

product a

product a-1 10 10/30

product a-2 20 20/30

sub total 30 30/100

product b

product b-1 20 20/70

product b-2 50 50/70

sub total 70 70/100

Total 100

Here is the calculation script below:

CREATE MEMBER CURRENTCUBE.[Product].[Div-Quad Hierarchy].[Total] AS 'SUM([ALL])'; /* I may change this but not clear now */

CREATE MEMBER CURRENTCUBE.[MEASURES].[% Contrib Sls $]

AS

'[Measures].[Net Sale Dollars_Prod]/([Measures].[Net Sale Dollars_Prod], [product].[Div-Quad Hierarchy].[Total])',

SOLVE_ORDER=2,

FORMAT_STRING = "Percent",

VISIBLE = 1 ;

Please give me any comments.

Thanks in advance Smile

|||

Dear abc,

I'm happy you get it!! :-)

I will try to help you in your new requirement more late (few hours), ok? At the moment I'm very, very busy! :-(

Regards!!!

|||

Hi Pedro,

It seems you are busy Sad

If I run the mdx query,I can get a right result for each product level if I change this area that I highlighted in yellow.

But if I add this member in the calculation script then I don't know how to apply this for each particular product level.

FYI, I have product hierarchy (division > Q > Q name > ...) and we want to see the contribution percent in the total amount of the each product level not grand total of total products.

MEMBER [Product].[Div-Quad Hierarchy].[Total] AS

'SUM([Product].[Div-Quad Hierarchy].[division].&[interesting product name ])'

MEMBER [MEASURES].[Percentage] AS

'[Measures].[Net Purch Dollars_prod]/([Measures].[Net Purch Dollars_prod], [product].[Div-Quad Hierarchy].[Total])',

SOLVE_ORDER=2,

FORMAT_STRING="percent"

Please give me some comments.

Thanks in advance.

calculation question

Hi,

how can write MDX in calculation for this case I highlighted in red?

product Sale contribution

-

a | 30.00 30/80 = 0.375

b | 50.00 50/80 =0.625

total | 80.00

-

[measures].[sale]/ sum ([measures].[sale] in current level ) ?

Thanks in advance.

Dear Friend,

try this and tell me if works:

Code Snippet

WITH
SET [InterestingProduts] AS
'{[Product].&[2],
[Product].&[1]}'

MEMBER [Product].[TotalOfInterestingProducts] AS
'SUM([InterestingProduts])'
MEMBER [MEASURES].[Percentage] AS
'[Measures].[Sales]/([Measures].[Sales],[Product].[TotalOfInterestingProducts])',

SOLVE_ORDER=5

SELECT {[Measures].[Sales],[MEASURES].[Percentage]} ON COLUMNS,
{[Product].members,[Product].[TotalOfInterestingProducts]} ON ROWS
FROM [YourCube]

Is more completed... but try if works!

regards!

|||

Hi PedroCGD,

Thanks for your code Smile

It works perfectly.

And I have another challenge that if I want to view percentage in each level (please see the example below) then how should I define for this scnario?

Currently, it only works in product a / b level. If I drill down and see the percentage then it calculates like this below:

i.g. product a-1 : 10/100 --> want to correct 10/30

product a-2: 20/ 100 > want to correct 20/30

percentage

product a

product a-1 10 10/30

product a-2 20 20/30

sub total 30 30/100

product b

product b-1 20 20/70

product b-2 50 50/70

sub total 70 70/100

Total 100

Here is the calculation script below:

CREATE MEMBER CURRENTCUBE.[Product].[Div-Quad Hierarchy].[Total] AS 'SUM([ALL])'; /* I may change this but not clear now */

CREATE MEMBER CURRENTCUBE.[MEASURES].[% Contrib Sls $]

AS

'[Measures].[Net Sale Dollars_Prod]/([Measures].[Net Sale Dollars_Prod], [product].[Div-Quad Hierarchy].[Total])',

SOLVE_ORDER=2,

FORMAT_STRING = "Percent",

VISIBLE = 1 ;

Please give me any comments.

Thanks in advance Smile

|||

Dear abc,

I'm happy you get it!! :-)

I will try to help you in your new requirement more late (few hours), ok? At the moment I'm very, very busy! :-(

Regards!!!

|||

Hi Pedro,

It seems you are busy Sad

If I run the mdx query,I can get a right result for each product level if I change this area that I highlighted in yellow.

But if I add this member in the calculation script then I don't know how to apply this for each particular product level.

FYI, I have product hierarchy (division > Q > Q name > ...) and we want to see the contribution percent in the total amount of the each product level not grand total of total products.

MEMBER [Product].[Div-Quad Hierarchy].[Total] AS

'SUM([Product].[Div-Quad Hierarchy].[division].&[interesting product name ])'

MEMBER [MEASURES].[Percentage] AS

'[Measures].[Net Purch Dollars_prod]/([Measures].[Net Purch Dollars_prod], [product].[Div-Quad Hierarchy].[Total])',

SOLVE_ORDER=2,

FORMAT_STRING="percent"

Please give me some comments.

Thanks in advance.

Tuesday, February 14, 2012

Calculating movement

Hello all,
I've been scratching my brain on this one but so far no result.
we have table with daily product availability and I would like to know which products have the highest rotation.

Example:

date product stock
1/1/2005 x 5
2/1/2005 x 4 (sold 1)
3/1/2005 x 1 (sold 3)
4/1/2005 x 10 (purchased 9)
1/1/2005 y 0
2/1/2005 y 5 (purchased 5)
3/1/2005 y 1 (sold 4)
4/1/2005 y 3 (purchased 2)
...


Is it possible to obtain for each product the sum of the 'sold' items, in this case it would be product x: 4 and product y: 4

Any deas would be really most welcome

Thanks & merry christmas to all

MichaelIf the dates in your table increment by 1 all the time, you could try this:SELECT p1.product, SUM(p1.stock - p2.stock) sold
FROM product p1, product p2
WHERE p1.product = p2.product
AND p2.stock < p1.stock
AND p2.dt = p1.dt + 1
GROUP BY p1.product;
But, if you have gaps between dates, you'll need a subquery to find out the right date:... AND p2.dt =
(SELECT MIN(p3.dt) FROM product p3
WHERE p3.product = p1.product
AND p3.dt > p1.dt
)
I hope this helps ...