SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Required Each Geography Group wise product maximum sales report (Using mdx)


Required Each Geography Group wise product maximum sales report (Using mdx)

Author
Message
narendra.babu57
narendra.babu57
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 215
Hi,
My table structure having bellow format :

State ProductID Sales
Ap P1 80
Ap p2 10
Ap p3 10
Tn P1 25
Tn p2 50
Tn p3 25
Mp p1 20
Mp p2 70
Mp p3 10

Required output is :
State ProductID sales
Ap p1 80
Tn p2 50
Mp p3 70

Regards,
Narendra
pietlinden
pietlinden
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4849 Visits: 13165
Looks like your example data is wrong. Without an explanation of the rules, this is as close as I could get:


SELECT x.*, y.productID
FROM
(SELECT xState
, MAX(Sales) AS MaxSales
FROM salesData
GROUP BY xState) X
INNER JOIN salesData Y ON X.xState=Y.xState
AND X.MaxSales=Y.Sales



Here's the result I got:
xState MaxSales productID
Ap 80 P1
Mp 70 p2
Tn 50 p2
narendra.babu57
narendra.babu57
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 215
Hi,
I required output in mdx not in sql server . Any how i got the solution FYI


WITH SET Top10Cust AS
[DimGeographyBuyer].[State].[State]

set topP as
Generate( {Top10Cust}, CrossJoin( {[DimGeographyBuyer].[State].CurrentMember},
TopCount([DimProduct].[MaterialId].[MaterialId].Members, 1, ([Measures].[DistributorSalesSum]))))

SELECT
{([Measures].[DistributorSalesSum]) } ON COLUMNS ,

non empty {topP}
ON ROWS

FROM (SELECT ( { [MarketYear].[MarketYearHierarchy].[MARKETYEAR].&[2014] } ) ON COLUMNS

FROM
[MyCube])
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search