Multiply Dimension item with the numeric values - mdx

I have Dimension column as Price and the Measure column as Quantity, I want to multiply price with the quantity,Please help me write MDX.
I tried with the below query.
With Member [Measures].[A] As ([Part ID].[Price]), Format_String ='Number'
Member [Measures].[B] As [Measures].[Quantity] * [Measures].[A]
Select {[Measures].[A],[Measures].[B]} On Columns, NON EMPTY( [Part ID].[Part Id].Children ) On Rows from [studio_bomdata]

You just need the following change
With Member [Measures].[A] As ([Part ID].[Price].CurrentMember.Properties ("Member_Value",TYPED)
)

Related

MDX query to except specific date from date range

I am need to delete all 2 month from set. This code return all date range without excepting 2 month.
SELECT
{[Measures].[In]} ON COLUMNS,
EXCEPT([Date].[2014].[1] : [Date].[2016].[2], [Date].[Month].[2]) ON ROWS
FROM [Shop hourly]
Print screen for whytheq
My decision based on whytheq answear. I create a dimension for all kind of dates, and except them. Example:
SELECT {[Measures].[In sum]} ON COLUMNS,
NON EMPTY
{[Shop].[11], [Shop].[22], [Shop].[33]} *
Except([Quarter].Children, [Quarter].[2]) *
[Month].Children ON ROWS
FROM [Shop hourly]
WHERE
([Date].[2013].[1].[1] : [Date].[2016].[1].[1]) *
Except([Year].Children, [Year].[2014])
In AdventureWorks I can do the following:
SELECT
[Measures].[Internet Sales Amount] ON 0
,NON EMPTY
Except
(
[Date].[Calendar].[Month].&[2005]&[7]
:
[Date].[Calendar].[Month].&[2008]&[7]
,Exists
(
[Date].[Calendar].[Month].MEMBERS
,[Date].[Calendar Quarter of Year].&[CY Q3]
)
) ON 1
FROM [Adventure Works];
So adapting the above to your cube maybe looks like the following:
SELECT
{[Measures].[In]} ON COLUMNS
,Except
(
[Date].[2014].[1] : [Date].[2016].[2]
,Exists
(
[Date].MEMBERS
,[Date].[Month].[2]
)
) ON ROWS
FROM [Shop hourly];

MDX: I need column count based on the total rows

Here we have total 14 rows, I need one more column (RowCount-Column name)
every-cell contains 14 (reputation) means total row counts.
below is the query
WITH MEMBER DimName AS [DimClinic].[Provider Key].CurrentMember.Member_Caption
MEMBER DimKey AS [DimClinic].[Provider Key].CurrentMember.Member_Key
SELECT {[Measures].DimKey ,
[Measures].DimName ,
[Measures].[DrPatientKeyCnt]} ON COLUMNS ,
NonEmpty([DimClinic].[Provider Key].[Provider Key])ON ROWS
FROM [PopulationReportCube]
WITH
MEMBER DimName AS
[DimClinic].[Provider Key].CurrentMember.Member_Caption
MEMBER DimKey AS
[DimClinic].[Provider Key].CurrentMember.Member_Key
MEMBER RowCount AS
Count
(
NonEmpty
(
[DimClinic].[Provider Key].[Provider Key]
,[Measures].[DrPatientKeyCnt]
)
)
SELECT
{
[Measures].DimKey
,[Measures].DimName
,[Measures].[DrPatientKeyCnt]
,[Measures].[RowCount]
} ON COLUMNS
,NonEmpty([DimClinic].[Provider Key].[Provider Key]) ON ROWS
FROM [PopulationReportCube];

MDX Query Column name for Measures

have following query
select
non empty
(
[Dimension1].[Description].children,
[Dimension1].[GCode].members,
[Measures].[GScore Sum]
)
on columns,
non empty
(
[Dimension2].[DCode].[DCode] *
[Dimension2].[DName].[DName] *
[Dimension2.[Barcode].[Barcode] *
[Dimension2].[LN].[LName] *
[Dimension2].[FN].[FName]
)
on rows
from
[MCube]
where
(
{[Dimension2].[HARC].[DCode].&[0000]}
)
In the results [GSCORE SUM] column name repeats is eachtheir way to avoid the repeation of column name or give the unique name for EACH GLCE Code member instead of just repetting [GSCore Sum] in results or make the [Gscore Sum] invisible
http://i.stack.imgur.com/yte59.jpg
Not 100% sure what you require but have you tried adding the measure to the WHERE clause?:
select
non empty
(
[Dimension1].[Description].children,
[Dimension1].[GCode].members
)
on columns,
non empty
(
[Dimension2].[DCode].[DCode] *
[Dimension2].[DName].[DName] *
[Dimension2.[Barcode].[Barcode] *
[Dimension2].[LN].[LName] *
[Dimension2].[FN].[FName]
)
on rows
from
[MCube]
where
(
[Measures].[GScore Sum],
{[Dimension2].[HARC].[DCode].&[0000]}
)

MDX Calculated Dimension Member base on another dimension

There are two dimensions
[record].[record id]
[product].[product name]
[measures].[sales]
I want to create a new dimension attribute, in the record dimension.
with member [record].[derived record id] as iif([product].[product name].[product name]
in ('pen', 'eraser', 'notepad'), 0, [record].[record id].[record id])
select [measures].[sales] on 0,
[record].[derived record id].[derived record id] on 1
You see what I am trying to do is to combine some the the rows where product name is in a select list and leave the rest as is. I can do this during the load process to create this new attribute, but how do I do it in MDX?
Thanks in advance.
As far as I understand, you want to have a calculated member of the [record].[record id] hierarchy that delivers the value 0 for all measures in the cube in case the current product name member is one of 'pen', 'eraser', and 'notepad'. To achieve this, you can use the following MDX:
with member [record].[record id].[derived record id] -- note: you must name the hierarchy for calculated members
as
IIf([product].[product name].CurrentMember IS [product].[product name].[pen]
or
[product].[product name].CurrentMember IS [product].[product name].[eraser]
or
[product].[product name].CurrentMember IS [product].[product name].[notepad]
,
0
,
Measures.CurrentMember
)
select [measures].[sales]
on 0,
[record].[record id].[derived record id]
on 1
from [YourCube]

need to get sum of all members of a dimension minus one member

I am trying to make an MDX query that can tell me how many products were sold in countries other than China. With the following query I can only get the units sold of bottled water for each of the countries, but not their sum. How do I modify the query to get the sum of that ?
SELECT NON EMPTY Except(
{[Location].[All Places].Children},
{[Location].[China]}
) ON COLUMNS,
{[Product].[All Products].[Bottled Water].Children} ON ROWS
FROM [Places]
WHERE [Measures].[Units Sold]
The following should do what you want:
WITH
SET [countries] as Except( {[Location].[All Places].Children}, {[Location].[China]} )
MEMBER [measures].[X] as Sum( [countries] , [Measures].[Units Sold] )
SELECT {[Product].[All Products].[Bottled Water].Children} ON ROWS
FROM [Places]
WHERE [measures].[x]