Error adding new column - reporting-services

I'm trying to add an "account subcategory" column to my report using the query builder.
I added the column and got the error message:
"An MDX expression was expected. An empty expression was specified."
How do I format the MDX in order to get the result I am looking for?
I posted the code below. Hope this helps.
SELECT NON EMPTY { [Measures].[Order Partic Adj], [Measures].[PY Net Cash], [Measures].[Order Merch Adj], [Measures].[OCCURS - APY BOOKING FACT], [Measures].[PY Orders], [Measures].[Net Cash Merch Adj], [Measures].[Net Cash Acq Adj], [Measures].[Total Proj Orders], [Measures].[Order Acq Adj], [Measures].[Net Cash Partic Adj], [Measures].[Total Proj Net Cash] } ON COLUMNS, NON EMPTY { ([Current Assignment].[Territory Code].[Territory Code].
ALLMEMBERS * [Current Assignment].[Sales Rep Name Caps].[Sales Rep Name Caps].
ALLMEMBERS * [Current Assignment].[Sales Rep Employee Code].[Sales Rep Employee Code].
ALLMEMBERS * [Account].[Account Subcategory Name].[Account Subcategory Name].
ALLMEMBERS * [Account].[ACCOUNT NAME].[ACCOUNT NAME].
ALLMEMBERS * [Account].[LIFETOUCH ID].[LIFETOUCH ID].
ALLMEMBERS * [Account].[NACAM Ordered].[NACAM Ordered].
ALLMEMBERS * [Account].[ENROLLMENT COUNT].[ENROLLMENT COUNT].
ALLMEMBERS * [Account].[STATE].[STATE].
ALLMEMBERS * [Account].[District Name].[District Name].
ALLMEMBERS * [Account].[City].[City].
ALLMEMBERS * [Account].[COUNTY].[COUNTY].
ALLMEMBERS * [APY].[BOOKING STATUS].[BOOKING STATUS].
ALLMEMBERS * [APY].[X BOOKING STATUS ID].[X BOOKING STATUS ID].
ALLMEMBERS * [APY].[AT RISK IND].[AT RISK IND].
ALLMEMBERS * [APY].[INCENTIVE ACQUISITION IND].[INCENTIVE ACQUISITION IND].
ALLMEMBERS * [APY].[CY BOOKING CAMERA TYPE NAME].[CY BOOKING CAMERA TYPE NAME].
ALLMEMBERS * [APY].[CURRENT YEAR SELLING METHODS].[CURRENT YEAR SELLING METHODS].
ALLMEMBERS * [APY].[PY ACTUAL CAMERA TYPE NAME].[PY ACTUAL CAMERA TYPE NAME].
ALLMEMBERS * [APY].[ACQUIRED BUSINESS NAME].[ACQUIRED BUSINESS NAME].
ALLMEMBERS * [APY].[PRIOR YEAR SELLING METHODS].[PRIOR YEAR SELLING METHODS].
ALLMEMBERS * [Marketing].[SUB PROGRAM NAME].[SUB PROGRAM NAME].
ALLMEMBERS * [Current Assignment].[AMS Business Unit Name].[AMS Business Unit Name].
ALLMEMBERS * [Account].[POSTAL CODE].[POSTAL CODE].
ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( STRTOSET(#APYBOOKINGSTATUS, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#CurrentAssignmentSalesRepNameCaps, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#CurrentAssignmentTerritoryCode, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#CurrentAssignmentRegionName, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#CurrentAssignmentAreaName, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#CurrentAssignmentAMSBusinessUnitName, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#CurrentAssignmentCountryName, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#SchoolYearSCHOOLYEAR, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#MarketingSUBPROGRAMNAME, CONSTRAINED) ) ON COLUMNS FROM [BO_APY_Booking_Fact_Full]))))))))) WHERE ( IIF( STRTOSET(#SchoolYearSCHOOLYEAR, CONSTRAINED).Count = 1, STRTOSET(#SchoolYearSCHOOLYEAR, CONSTRAINED), [School Year].[SCHOOL YEAR].currentmember ), IIF( STRTOSET(#CurrentAssignmentCountryName, CONSTRAINED).Count = 1, STRTOSET(#CurrentAssignmentCountryName, CONSTRAINED), [Current Assignment].[Country Name].currentmember ), IIF( STRTOSET(#CurrentAssignmentAreaName, CONSTRAINED).Count = 1, STRTOSET(#CurrentAssignmentAreaName, CONSTRAINED), [Current Assignment].[Area Name].currentmember ), IIF( STRTOSET(#CurrentAssignmentRegionName, CONSTRAINED).Count = 1, STRTOSET(#CurrentAssignmentRegionName, CONSTRAINED), [Current Assignment].[Region Name].currentmember ) ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Related

is specified twice, both as a target for 'UPDATE' and as a separate source for data

UPDATE TempdataDB
SET discountPrice = price - (
SELECT (
SELECT '10.75' / (
SELECT count(*) FROM TempdataDB
)
) / quantity FROM TempdataDB
)
result same ERROR ... ANY help ?

How to add ORDER to an MDX based parameter

How can I change the following data set query to order by Employee Name
WITH
MEMBER [Measures].[ParameterCaption] AS
[Employee].[Employee Name].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS
[Employee].[Employee ID].CURRENTMEMBER.UNIQUENAME
MEMBER [Measures].[ParameterLevel] AS
[Employee].[Employee ID].CURRENTMEMBER.LEVEL.ORDINAL
SELECT
{[Measures].[ParameterCaption]
, [Measures].[ParameterValue]
, [Measures].[ParameterLevel]} ON COLUMNS ,
[Employee].[Employee ID].ALLMEMBERS ON ROWS
FROM ( SELECT ( STRTOSET(#ReportingCurrencyReportingCurrency, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#PROJGROUPProjGroup, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#CompanyCompanyAccounts, CONSTRAINED) ) ON COLUMNS FROM [ACTIVITY])))
You can try adding the ORDER function - although I'll need to test as I'm unsure this will work:
WITH
MEMBER [Measures].[ParameterCaption] AS
[Employee].[Employee Name].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS
[Employee].[Employee ID].CURRENTMEMBER.UNIQUENAME
MEMBER [Measures].[ParameterLevel] AS
[Employee].[Employee ID].CURRENTMEMBER.LEVEL.ORDINAL
SELECT
{[Measures].[ParameterCaption]
, [Measures].[ParameterValue]
, [Measures].[ParameterLevel]} ON COLUMNS ,
ORDER(
[Employee].[Employee ID].ALLMEMBERS,
[Measures].[ParameterCaption],
BDESC
)ON ROWS
FROM ( SELECT ( STRTOSET(#ReportingCurrencyReportingCurrency, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#PROJGROUPProjGroup, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(#CompanyCompanyAccounts, CONSTRAINED) ) ON COLUMNS FROM [ACTIVITY])))

RANKING Function in DAX or MDX

How can i get result in attached image by DAX or MDX.Both can work for me.
( I will use DAX in Tabular Model and Will use MDX on SSRS part).
Sample Format
I tried below code but it didn't work.
WITH
SET OrderSet AS
Order
(
(
[Dim Product].[Category Name].[Category Name].MEMBERS
,[Dim Product].[Subcategory Name].[Subcategory Name].MEMBERS
,[Dim Product].[Sub Subcategory Name].[Sub Subcategory Name].MEMBERS
,[Dim Product].[Product Name].[Product Name].MEMBERS
)
,[Measures].[Order Quantity]
,BDESC
)
MEMBER [Measures].[RankOrderCount] AS
Rank
(
(
[Dim Product].[Category Name].CurrentMember
,[Dim Product].[Subcategory Name].CurrentMember
,[Dim Product].[Sub Subcategory Name].CurrentMember
,[Dim Product].[Product Name].CurrentMember
)
,OrderSet
)
SELECT
{
[Measures].[Order Quantity]
,[Measures].[RankOrderCount]
} ON 0
,NON EMPTY
{OrderSet} ON 1
FROM [Adventure Works DW2016CTP3];
I don't understand the problem. If I run this:
WITH
SET OrderSet AS
Order
(
(
[Product].[Category].[Category].MEMBERS
,[Product].[Subcategory].[Subcategory].MEMBERS
)
,[Measures].[Order Quantity]
,BDESC
)
MEMBER [Measures].[RankOrderCount] AS
Rank
(
(
[Product].[Category].CurrentMember
,[Product].[Subcategory].CurrentMember
)
,OrderSet
)
SELECT
{
[Measures].[Order Quantity]
,[Measures].[RankOrderCount]
} ON 0
,NON EMPTY
{OrderSet} ON 1
FROM [Adventure Works];
I get this:
This looks like your desired output format - but I did not change the script - so what is the question?
For example:
DEFINE
VAR TableTMP1 =
SELECTCOLUMNS (
DimProductTable,
"Product Name", DimProductTable[Product Name],
"Sub Subcategory Name", RELATED ( SubSubcategoryTable[Sub Subcategory Name] ),
"Subcategory Name", RELATED ( SubcategoryTable[Subcategory Name] ),
"Category Name", RELATED ( CategoryTable[Category Name] )
)
VAR TableTMP2 =
ADDCOLUMNS (
TableTMP1,
"Order Count", CALCULATE ( SUM ( OrderTable[Quantity] ) )
)
EVALUATE
ADDCOLUMNS ( TableTMP2, "Rank", RANKX ( TableTMP2, [Order Count], ASC ) )
ORDER BY [Rank] ASC

Unpivot columns of cube for SSRS report

I need to modify a report that has a ton of fields to pivot some columns. It uses a SSAS cube. I don't know MDX and learning it for this task isn't really feasible.
Example: Existing
Date Amount SalesPerson1 Salesperson2 Manager 1 Product nbr
4/1/15 100 JSMtih JDoe TPrice 99
New Results
Participant Participant Role Date Amount Product Nbr
JSmith SalesPerson1 4/1/15 100 99
JDOE Salesperson2 4/1/15 100 99
TPRice Manager1 4/1/15 100 99
I could rewrite the report using SQL and do an UNPIVOT (I did write the query), but to reconstruct the report would be a ton of work (it has around 10 cascading parameters, sections that collapse/expand, etc.)
Is modifying the MDX to unpivot some columns easy? I couldn't find an unpivot for MDX and I am guessing it is just inherent in MDX.
MDX Code:
SELECT
NONEMPTY({
[Measures].[Outstanding Balance],
[Measures].[TM Fee],
[Measures].[Upfront Fee],
[Measures].[Non Recurring Fee],
[Measures].[Recurring Fee],
[Measures].[Syndication Fee],
[Measures].[Recap Fee],
[Measures].[International Fee],
[Measures].[Total Deposits Expected],
[Measures].[ACE],
[Measures].[Commitments],
[Measures].[Swap Fee],
[Measures].[Global Commitment],
[Measures].[Loan Fundings Expected One],
[Measures].[Loan Fundings Expected Two],
[Measures].[Change Amount],
[Measures].[Total Fees],
[Measures].[Private Balance]
}) ON COLUMNS,
NONEMPTY ({(
[Account].[Account Number].[Account Number].ALLMEMBERS *
[Account].[Non Accrual Flag].[Non Accrual Flag].ALLMEMBERS *
[Deal].[Deal ID].[Deal ID].ALLMEMBERS *
[Deal].[Hierarchy Type].[Hierarchy Type].ALLMEMBERS *
[Deal].[Officer One].[Officer One].ALLMEMBERS *
[Deal].[Officer Two].[Officer Two].ALLMEMBERS *
[Deal].[Other Competing Banks].[Other Competing Banks].ALLMEMBERS *
[Deal].[Winning Bank].[Winning Bank].ALLMEMBERS *
[Deal].[Officer Three].[Officer Three].ALLMEMBERS *
[Deal].[Group].[Group].ALLMEMBERS *
[Deal].[Competitor One].[Competitor One].ALLMEMBERS *
[Deal].[Incumbentbank].[Incumbentbank].ALLMEMBERS *
[Deal].[Competitor Two].[Competitor Two].ALLMEMBERS *
[Deal].[New Target Market].[New Target Market].ALLMEMBERS *
[Deal].[Approval Description].[Approval Description].ALLMEMBERS *
[Deal].[Loan Disposition].[Loan Disposition].ALLMEMBERS *
[Deal].[Process Center].[Process Center].ALLMEMBERS *
[Deal].[Process Job].[Process Job].ALLMEMBERS *
[Deal].[Deal Type].[Deal Type].ALLMEMBERS *
[Deal].[Screener].[Screener].ALLMEMBERS *
[Deal].[Part Or Synd].[Part Or Synd].ALLMEMBERS *
[Deal].[Department].[Department].ALLMEMBERS *
[Deal].[Party Package Id].[Party Package Id].ALLMEMBERS *
[Deal].[Stage].[Stage].ALLMEMBERS *
[Deal].[Stage Date].[Stage Date].ALLMEMBERS *
[Deal].[Referral].[Referral].ALLMEMBERS *
[Deal].[Deal NAICS Code].[Deal NAICS Code].ALLMEMBERS *
[Deal].[Document Type].[Document Type].ALLMEMBERS *
[Deal].[Internal Referral].[Internal Referral].ALLMEMBERS *
[Deal].[External Referral].[External Referral].ALLMEMBERS *
[Deal].[Referral Category].[Referral Category].ALLMEMBERS *
[Deal].[Underwriter].[Underwriter].ALLMEMBERS *
[Deal].[Product Partner1].[Product Partner1].ALLMEMBERS *
[Deal].[Product Partner2].[Product Partner2].ALLMEMBERS *
[Deal].[Manager1].[Manager1].ALLMEMBERS *
[Deal].[Manager2].[Manager2].ALLMEMBERS *
[Deal].[Other Participant].[Other Participant].ALLMEMBERS *
[Deal].[Agent].[Agent].ALLMEMBERS *
[Deal].[Deal Source].[Deal Source].ALLMEMBERS *
[Deal].[Target Market Client].[Target Market Client].ALLMEMBERS *
[Deal].[Reason].[Reason].ALLMEMBERS *
[Deal].[Client Status As Of Deal Input].[Client Status As Of Deal Input].ALLMEMBERS *
[Deal].[Source System].[Source System].ALLMEMBERS *
[Deal].[Stage ID].[Stage ID].ALLMEMBERS *
[Deal].[ABLBDO].[ABLBDO]. ALLMEMBERS *
[Party].[Customer Number].[Customer Number].ALLMEMBERS *
[Party].[Party NAICS Code].[Party NAICS Code].ALLMEMBERS *
[Party].[Party Name].[Party Name].ALLMEMBERS *
[Party].[Name].[Name].ALLMEMBERS *
[Product].[Product Type Number].[Product Type Number].ALLMEMBERS *
[Product].[CB Description].[CB Description].ALLMEMBERS *
[Service Transaction].[Service Transaction Key].[Service Transaction Key].ALLMEMBERS *
[Service Transaction].[Expected Funding Date Two].[Expected Funding Date Two].ALLMEMBERS *
[Service Transaction].[Expected Funding Date One].[Expected Funding Date One].ALLMEMBERS *
[Service Transaction].[Gross Revenue Date].[Gross Revenue Date].ALLMEMBERS *
[Service Transaction].[Loan Action].[Loan Action].ALLMEMBERS *
[Service Transaction].[Queue Creation Date].[Queue Creation Date].ALLMEMBERS *
[Service Transaction].[Loan Open Date].[Loan Open Date].ALLMEMBERS *
[Service Transaction].[Comments].[Comments].ALLMEMBERS *
[Service Transaction].[Next Maturity Date].[Next Maturity Date].ALLMEMBERS *
[Service Transaction].[Creation Date].[Creation Date].ALLMEMBERS *
[Service Transaction].[Total Loan Fundings Expected].[Total Loan Fundings Expected].ALLMEMBERS *
[Service Transaction].[Risk Rating].[Risk Rating].ALLMEMBERS *
[Service Transaction].[Last Modified On].[Last Modified On].ALLMEMBERS *
[Service Transaction].[Revenue].[Revenue].ALLMEMBERS *
[Service Transaction].[Note Rate].[Note Rate].ALLMEMBERS *
[Service Transaction].[RLOC Stock UDF].[RLOC Stock UDF].ALLMEMBERS *
[Service Transaction].[Basis Points].[Basis Points].ALLMEMBERS *
[Service Transaction].[Pricing Index].[Pricing Index].ALLMEMBERS *
[Service Transaction].[Law Firm].[Law Firm].ALLMEMBERS *
[Service Transaction].[Cost Center].[Cost Center].ALLMEMBERS *
[Service Transaction].[Expected Funding Date].[Expected Funding Date].ALLMEMBERS *
[Service Transaction].[Year].[Year].ALLMEMBERS *
[Service Transaction].[Estimated Closing Date].[Estimated Closing Date].ALLMEMBERS *
[Service Transaction].[Expected Funding Month].[Expected Funding Month].ALLMEMBERS *
[Service Transaction].[Expected Deposit Funding Date].[Expected Deposit Funding Date].ALLMEMBERS *
[Pipeline Dates].[Approved Date].[Approved Date].ALLMEMBERS *
[Pipeline Dates].[Closed Date].[Closed Date].ALLMEMBERS *
[Pipeline Dates].[Declined Date].[Declined Date].ALLMEMBERS *
[Pipeline Dates].[Discussion Date].[Discussion Date].ALLMEMBERS *
[Pipeline Dates].[Documentation Date].[Documentation Date].ALLMEMBERS *
[Pipeline Dates].[Lost Date].[Lost Date].ALLMEMBERS *
[Pipeline Dates].[PAR Date].[PAR Date].ALLMEMBERS *
[Pipeline Dates].[Proposal Date].[Proposal Date].ALLMEMBERS *
[Pipeline Dates].[Suspended Date].[Suspended Date].ALLMEMBERS *
[Pipeline Dates].[Term Sheet Date].[Term Sheet Date].ALLMEMBERS *
[Pipeline Dates].[Underwriting Date].[Underwriting Date].ALLMEMBERS *
[Pipeline Dates].[Withdrawn Date].[Withdrawn Date].ALLMEMBERS
)}) DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM (
SELECT ( STRTOSET(#DealDocumentType, CONSTRAINED) ) ON COLUMNS FROM (
SELECT ( STRTOSET(#DealDealType, CONSTRAINED) ) ON COLUMNS FROM (
SELECT ( STRTOSET(#ProductProductDescription, CONSTRAINED) ) ON COLUMNS FROM (
SELECT ( STRTOSET(#DealNonPrimaryOfficer, CONSTRAINED) ) ON COLUMNS FROM (
SELECT ( STRTOSET(#DealOfficerOne, CONSTRAINED) ) ON COLUMNS FROM (
SELECT ( STRTOSET(#DealClientStatusAsOfDealInput, CONSTRAINED) ) ON COLUMNS FROM (
SELECT ( STRTOSET(#ServiceTransactionCostCenter, CONSTRAINED) ) ON COLUMNS FROM (
SELECT ( STRTOSET(#DealGroup, CONSTRAINED) ) ON COLUMNS FROM (
SELECT ( STRTOSET(#ClosingDateCalendar, CONSTRAINED) ) ON COLUMNS FROM (
SELECT ( STRTOSET(#DealStage, CONSTRAINED) ) ON COLUMNS FROM [Pipeline]
)
)
)
)
)
)
)
)
)
)
You could use UNION to get a set with all the people in the same column.
But that maybe not produce the same results you want.
You would be getting the "Totals" for Manager1 and Manager2. Give it a try.
WITH
SET myPeople
AS
UNION(
[Deal].[Manager1].[Manager1].ALLMEMBERS,
[Deal].[Manager2].[Manager2].ALLMEMBERS,
[Deal].[Agent].[Agent].ALLMEMBERS
)
I would start with the following:
Download & install OLAP PivotTable Extensions from https://olappivottableextend.codeplex.com/
Open Excel and connect to your Cube
Build your query/report using drag and drop attributes.
Use plugin to copy the required MDX Query and edit as required.

MDX How to calculate measure against dimension without displaying members in results

Could someone please help me with the below MDX problem:
I got the dataset like the one below:
With
Set Range1 as {[Date].[Calendar].[Month].&[2008]&[1]
:[Date].[Calendar].[Month].&[2008]&[12]}
Set Range2 as
{[Delivery Date].[Calendar].[Month].&[2008]&[1]:
[Delivery Date].[Calendar].[Month].&[2008]&[12]}
MEMBER measures.A as [Measures].[Internet Order Count] + [Measures].[Reseller Order Count]
select {[Measures].[Internet Order Count],A} on columns,
non empty(
[Sales Territory].[Sales Territory Country].[Sales Territory Country]*
Range1
*Range2
)
having [Date].[Calendar].currentmember.member_caption
= [Delivery Date].[Calendar].currentmember.member_caption
AND A > 100
on rows
from [Adventure Works]
The problem is that results are displayed with [Sales Territory] Dimension - I would like to get the results only displaying months but with measure A also calculated against [Sales Territory].
The results for measure A should looks like:
For example: 1128 for January
The Correct results should looks like:
Thanks
Sorry - was unable to past the code:
WITH MEMBER [Measures].[A] AS
[Measures].[Internet Order Count] + [Measures].[Reseller Order Count]
SELECT
{ [Measures].[Internet Order Count], [Measures].[A] } ON COLUMNS,
[Date].[Calendar].[Month] ON ROWS
FROM (
SELECT { [Measures].[Internet Order Count] } ON COLUMNS,
Filter (
Filter ( [Date].[Calendar].[Month] * [Delivery Date].[Calendar].[Month], [Date].[Calendar].CurrentMember.Name = [Delivery Date].[Calendar].CurrentMember.Name ) * [Sales Territory].[Sales Territory Country].[Sales Territory Country],
[Measures].[Internet Order Count] + [Measures].[Reseller Order Count] > 100
) ON ROWS
FROM [Adventure Works]
)
WHERE [Date].[Calendar Year].[CY 2008]
I've ignored the ranges for now but this is as close as I can get:
WITH
MEMBER measures.c1 AS
[Date].[Calendar].CurrentMember.Member_Caption
MEMBER measures.c2 AS
[Delivery Date].[Calendar].CurrentMember.Member_Caption
MEMBER measures.x AS
IIF
(
measures.c1 = measures.c2
,
[Measures].[Internet Order Count] + [Measures].[Reseller Order Count]
,null
)
SET q AS
Filter
(
[Sales Territory].[Sales Territory Country].[Sales Territory Country]*
[Date].[Calendar].[Month].MEMBERS*
[Delivery Date].[Calendar].[Month].MEMBERS
,
measures.x > 100
)
SELECT
{measures.x} ON 0
,NON EMPTY
Extract
(
q
,[Date].[Calendar]
,[Delivery Date].[Calendar]
) ON 1
FROM [Adventure Works];
EDIT
The following gives two options for the Rows - option A and option B:
WITH
MEMBER measures.c1 AS
[Date].[Calendar].CurrentMember.Member_Caption
MEMBER measures.c2 AS
[Delivery Date].[Calendar].CurrentMember.Member_Caption
MEMBER measures.x AS
IIF
(
measures.c1 = measures.c2
,
[Measures].[Internet Order Count] + [Measures].[Reseller Order Count]
,null
)
SET q AS
Filter
(
[Sales Territory].[Sales Territory Country].[Sales Territory Country]*
[Date].[Calendar].[Month].&[2008]&[1]*
[Delivery Date].[Calendar].[Month].MEMBERS
,
measures.x > 100
)
SELECT
{measures.x} ON 0
//<<<<<Option A.try just this and sum the cells ....1128
,q
//<<<<<Option B.try just this and sum the cells ....1221
//,Extract
// (
// q
// ,[Date].[Calendar]
// ,[Delivery Date].[Calendar]
// )
ON 1
FROM [Adventure Works];
EDIT 2
This gives the correct answer - be mean of me not to reference the real author: https://social.msdn.microsoft.com/Forums/en-US/be750f75-0e39-41b8-9578-9dceb58a5865/strange-context-aware-behaviour-of-adventure-works-script?forum=sqlanalysisservices
WITH
MEMBER measures.c1 AS
[Date].[Calendar].CurrentMember.Member_Caption
MEMBER measures.c2 AS
[Delivery Date].[Calendar].CurrentMember.Member_Caption
MEMBER measures.[Calendar Month] AS
measures.c1
MEMBER measures.[Delivery Month] AS
measures.c2
MEMBER measures.x AS
IIF
(
measures.c1 = measures.c2
,
[Measures].[Internet Order Count] + [Measures].[Reseller Order Count]
,NULL
)
SELECT
{
measures.[Calendar Month]
,measures.[Delivery Month]
,measures.x
} ON COLUMNS
FROM [Adventure Works]
WHERE
{
NonEmpty
(
[Sales Territory].[Sales Territory].[Country].MEMBERS*
[Date].[Calendar].[Month].&[2008]&[1]*
[Delivery Date].[Calendar].[Month].MEMBERS
,measures.x
)
}
-
{
Filter
(
NonEmpty
(
[Sales Territory].[Sales Territory].[Country].MEMBERS*
[Date].[Calendar].[Month].&[2008]&[1]*
[Delivery Date].[Calendar].[Month].MEMBERS
,measures.x
)
,
measures.x < 100
)
};
You can filter with sales territory, by doing the following instead of your current from [Adventure Works]
from (
select {[Sales Territory].[Sales Territory Country].[Sales Territory Country]} on columns
from [Adventure Works]
)
Having said that, you can then remove the sales territory from here.. and just have Range1 * Range2
non empty(
[Sales Territory].[Sales Territory Country].[Sales Territory Country]
Range1
*Range2
)
You can then continue to filter, using the MDX Filter function
from (
select {[Sales Territory].[Sales Territory Country].[Sales Territory Country]} on columns
from
(
select {
FILTER (
[Date].[Calendar].MEMBERS
,[Date].[Calendar].currentmember.member_caption = [Delivery Date].[Calendar].currentmember.member_caption and A > 100
)
} on columns
[Adventure Works]
)
)
If you don't want to see [Sales Territory].[Sales Territory Country].[Sales Territory Country] in the final SELECT, you can use EXISTS clause in MDX
With
Set Range1 as {[Date].[Calendar].[Month].&[2008]&[1]
:[Date].[Calendar].[Month].&[2008]&[12]}
Set Range2 as
{[Delivery Date].[Calendar].[Month].&[2008]&[1]:
[Delivery Date].[Calendar].[Month].&[2008]&[12]}
MEMBER measures.A as [Measures].[Internet Order Count] + [Measures].[Reseller Order Count]
select {[Measures].[Internet Order Count],A} on columns,
non empty filter((
exists({Range1
*Range2}, [Sales Territory].[Sales Territory Country].[Sales Territory Country]
)), measures.A > 100)
having [Date].[Calendar].currentmember.member_caption
= [Delivery Date].[Calendar].currentmember.member_caption