I have an OLAP Mondrian cube published on JasperServer within MDX script
My cube looks like this:
The MDX code is the following:
select NON EMPTY {[Measures].[Time consumed]} ON COLUMNS,
NON EMPTY Hierarchize({([Users.User].[All Users.Users],[Projects.Project].[All Projects.Projects],[Tasks.Task].[All Tasks.Tasks], [Imputations.Imputation].[All Imputations.Imputations])}) ON ROWS
from [cubeSifast]
As I see in the display view i have standr columns nomination, so how may I change for example :
1. the column headers titles (circled with blue line)
2. the children titles which are the names of dimensions (yellow)
I think that can be within the calculated members with MDX
"with member as"
but how exatcly, any suggestions?
You could try it with a Set.
with
set myNewName
as
[Users.User].[All Users.Users].MEMBERS
select
NON EMPTY {[Measures].[Time consumed]} ON COLUMNS,
NON EMPTY Hierarchize({(myNewName,[Projects.Project].[All Projects.Projects],[Tasks.Task].[All Tasks.Tasks], [Imputations.Imputation].[All Imputations.Imputations])}) ON ROWS
from [cubeSifast]
Related
I have one dimension that I want to put into filter, and created calculated member that should dynamically show number of selected members from the dimension.
The dimension does not have an All member.
So this is my attempt
with member [Measures].[Count1] as count(existing(([MyDimension].[MyDimensionHierarchy].members)))
select [Measures].[Count1] on 0
from [MyCube] -- gives me 1
and this one will give me 2 which is correct:
with member [Measures].[Count1] as count(existing(([MyDimension].[MyDimensionHierarchy].members)))
select [Measures].[Count1] on 0
from [MyCube]
where ({[MyDimension].[MyDimensionHierarchy].[Member1], [MyDimension].[MyDimensionHierarchy].[Member2]})
But, the problem is that when I create calculated member with the formula above, and drag Count1 to the Excel pivot table, and drag MyDimension as filter, and when I do multi-select of the dimension members, I want the count to dynamically change as I change number of members that are selected.
But Count1 always stays equal to 1.
In a meantime I have found an answer:
The query that I wrote in the question actually is not the query that Excel pivot table sends to the cube. Excel pivot table generates query like this:
SELECT FROM (SELECT ({[MyDimension].[MyDimensionHierarchy].[Member1],[MyDimension].[MyDimensionHierarchy].[Member2]}) ON COLUMNS
FROM [MyCube])
WHERE ([Measures].[Count1])
The way this should be done is by using dynamic set that contains filtered members:
create dynamic set [SelectedMembers] as existing( [MyDimension].[MyDimensionHierarchy].members )
And then:
create member Measures.SelectedMembersCount as count([SelectedMembers])
So this set dynamically changes as different members are selected in the filter and SelectedMembersCount is dynamically changed along the way.
Struggling with a way to hide an expression on certain rows in my pivot table below. Basically, I want to be able to hide my expression 'Cumulative' when the FINANCIAL_PLAN_TYPE is not equal to 'OB_VARIANCE_TO_T1'. I figured out a way to change the text format on the lines with other FINANCIAL_PLAN_TYPE so that it appears hidden (what is showing in the picture below), but I'd really like the whole row to go away in these cases.
Additionally, I do not want to see a Total on the Cumulative lines if possible, but I do want to keep them on the Sum(AMOUNT) lines.
My expression for Cumulative is:
sum(aggr(Rangesum(above(sum({<YEAR={"$(vYear_Current)"},FINANCIAL_PLAN_TYPE={"OB_VARIANCE_TO_T1"}>}AMOUNT),0,MONTH_NUM)), FINANCIAL_PLAN_TYPE, MONTH_NUM))
I tried to use the function Only, as well as, I tried conditionally enabling/disabling the expression but I can't seem to get it to work. Any ideas would be great. Thanks!
FINAL SOLUTION:
1) Load Inline Table
Load * Inline
[MyDim
Cumulative
Vals
];
2) Created calculated dimension to combine the two desired dimensions into one and show blank ('') in cases that you don't want to show (this leaves one blank line on the pivot but there is probably a way to hide that too):
=If(MYDim='Cumulative' and FINANCIAL_PLAN_TYPE='OB_VARIANCE_TO_T1','Orig Budg Cumulative Variance',if(MYDim='Cumulative' and FINANCIAL_PLAN_TYPE='LE_VARIANCE_TO_T1','LE Cumulative Variance',if(MYDim <> 'Cumulative',FINANCIAL_PLAN_TYPE,'')))
3) Create a new expression that does one calculation in the case of your made up dimension = Value A and something else in case your calculated dimension = Value B
If(MYDim='Cumulative' and (FINANCIAL_PLAN_TYPE='OB_VARIANCE_TO_T1' OR FINANCIAL_PLAN_TYPE='LE_VARIANCE_TO_T1'),If(ColumnNo()=0,'',sum(aggr(Rangesum(above(sum({<YEAR={"$(vYear_Current)"}, DEPARTMENT={"20820"}, ACCT_TYPE={"Capital"}>}AMOUNT),0,MONTH_NUM)),
FINANCIAL_PLAN_TYPE, MONTH_NUM))),IF(MYDim='Vals', SUM({<ACCT_TYPE={"Capital"},DEPARTMENT={"20820"}>}AMOUNT)))
You cannot hide expression on some of the rows - not possible in Qlikview.
The workaround is to create a dummy floating table that holds the second column as a dimension and then use it in your chart instead of the two expressions. Then you will have one expression that says something like that :
If ( dummyField = 'Cummulative' and = 'OB_VARIANCE_TO_T1',
{Use your second expression here} ,
If (dummyField = 'sum(Amount)', {use your original first expression here}))
Regarding the Total, check out this link in the "Tricking the Pivot Table" section
I am learning MDX and I have a question to create a percentage.
Basically, I extract data from Google Analytics API for multiple sets of pages.
For each set, I extract the number of UniquePageviews.
The SQL columns looks like that:
date
deviceCategory
medium
uniquePageviews
transactions
set_of_page (the rows contain the name of the set of pages. To simplify: 1. First, 2. Second, 3. Third )
Brand (Brand A, Brand B)
Market (Market X, Market Y)
Here is the current view I have:
http://i.stack.imgur.com/ZTC30.png
What I want to have is the percentage of UniquePageviews from the set of page 1 to 2 and from 2 to 3 So: UniquePageviews 2/Uniquepageviews 1 & UniquePageviews 3/Uniquepageviews 2.
http://i.stack.imgur.com/xf2gc.png
Do you know a simple way to do that in MDX?
Here is the code I have for now to display the pageviews:
WITH
SET [~COLUMNS_Brand_Brand] AS
SET [~COLUMNS_Market_Market] AS
{[Market].[Market].Members}
SET [~COLUMNS_set_of_page segment_set_of_page] AS
{[set_of_page].[set_of_page].Members}
SET [~ROWS] AS
{[Date].[Date].Members}
SELECT
NON EMPTY NonEmptyCrossJoin([~COLUMNS_Brand_Brand], NonEmptyCrossJoin([~COLUMNS_Market_Market], [~COLUMNS_set_of_page_set_of_page])) ON COLUMNS,
NON EMPTY [~ROWS] ON ROWS
FROM [MySQL_Cube]
Thanks a lot!
At the moment your mdx is picking up the measure implicitly? All mdx queries need something to measure so your current script must be picking up the default cube measure - I'll call this [Measures].[NumTransactions].
Also your first SET seems to be blank. Therefore lets assume the full, explicit script is:
WITH
SET [~COLUMNS_Brand_Brand] AS {[Brand].[Brand].[All]}
SET [~COLUMNS_Market_Market] AS
{[Market].[Market].Members}
SET [~COLUMNS_set_of_page segment_set_of_page] AS
{[set_of_page].[set_of_page].Members}
SET [~ROWS] AS
{[Date].[Date].Members}
SELECT
NON EMPTY NonEmptyCrossJoin([~COLUMNS_Brand_Brand], NonEmptyCrossJoin([~COLUMNS_Market_Market], [~COLUMNS_set_of_page_set_of_page])) ON COLUMNS,
NON EMPTY [~ROWS] ON ROWS
FROM [MySQL_Cube]
WHERE [Measures].[NumTransactions];
I use MS SSAS so a little unsure of nitation that works with you but just to help me I'll switch to the * operator for cross-joins:
WITH
SET [~COLUMNS_Brand_Brand] AS {[Brand].[Brand].[All]}
SET [~COLUMNS_Market_Market] AS
{[Market].[Market].Members}
SET [~COLUMNS_set_of_page segment_set_of_page] AS
{[set_of_page].[set_of_page].Members}
SET [~ROWS] AS
{[Date].[Date].Members}
SELECT
NON EMPTY
[~COLUMNS_Brand_Brand]
*[~COLUMNS_Market_Market]
*[~COLUMNS_set_of_page_set_of_page] ON COLUMNS,
NON EMPTY [~ROWS] ON ROWS
FROM [MySQL_Cube]
WHERE [Measures].[NumTransactions];
I'm hoping (as untested and I'm a little unsure all context will be retained) that we can just add a custom meassure that divides the current page by the previous one to get the percentage:
WITH
SET [~COLUMNS_Brand_Brand] AS {[Brand].[Brand].[All]}
SET [~COLUMNS_Market_Market] AS
{[Market].[Market].Members}
SET [~COLUMNS_set_of_page segment_set_of_page] AS
{[set_of_page].[set_of_page].Members}
SET [~ROWS] AS
{[Date].[Date].Members}
MEMBER [Measures].[NumTransactionsPercent] AS
[set_of_page].CURRENTMEMBER
/ [set_of_page].CURRENTMEMBER.LAG(1)
SELECT
NON EMPTY
[~COLUMNS_Brand_Brand]
*[~COLUMNS_Market_Market]
*[~COLUMNS_set_of_page_set_of_page] ON COLUMNS,
NON EMPTY [~ROWS] ON ROWS
FROM [MySQL_Cube]
WHERE [Measures].[NumTransactionsPercent]; //[Measures].[NumTransactions];
I'm new to SSAS and need help with what would be equivalent to a where clause in SQL and I'm sure an easy answer for a MDX regular.
I have this pulling values for a multiple select parameter list in report builder but I need to filter out the contracts based on what project the user is currently viewing. Here is the query that is pulling all the values correctly.
WITH MEMBER [Measures].[ParameterCaption] AS [dimContracts].[ContractName].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS [dimContracts].[Contract Name].CURRENTMEMBER.UNIQUENAME
SELECT {[Measures].[ParameterCaption],
[Measures].[ParameterValue]} ON COLUMNS,
[dimContracts].[Contract Name].Children ON ROWS
FROM [cubeProjectEntities]
I need to add what would be equivalant to:
WHERE dimContracts.[Project Id] = 1
I've added which produces the correct filtered set but from here I don't know how to use the report parameter to get it to work. Every time I test it just gives and empty dataset. I have the parameter just printing on the page so I know that it is set correctly.
WHERE [dimContracts].[Project Id].[1]
This does not work:
WHERE [dimContracts].[Project Id].[#ProjectId]
And then in Report builder I will pass a parameter to the query to replace the 1 for #projectId.
Thanks for any help!
WITH MEMBER [Measures].[ParameterCaption] AS [dimContracts].[ContractName].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS [dimContracts].[Contract Name].CURRENTMEMBER.UNIQUENAME
SELECT {[Measures].[ParameterCaption],
[Measures].[ParameterValue]} ON COLUMNS,
[dimContracts].[Contract Name].Children ON ROWS
FROM [cubeProjectEntities]
Where (STRTOMEMBER(#projectid))
In MDX, the where clause is a slicer. Here's a good article about the differences between SQL and MDX.
Here's a link about using SSRS parameters with MDX queries. You'll actually want to pass the entire member name to the query rather than just the value (ex: [DimContracts].[Project ID].[1])
I have an ssrs matrix , the design of which looks like this :
The sql query used in the above dataset looks like this :
select [YEAR], [MONTH] as MONT , ProductName, NumberofSales from XYZ ;
When the report is run , My output looks like this :
Here , the Column Names 9 , 10 correspond to the months 9 - September and 10 - October.
Change shows the difference in numbers between the month and the previous month . example :
number of sales in october - number of sales in september.
I would like to remove the column that I have circled in the above picture . Could you please let me know how I can do this . ??
I already tried right clicking the Change column and changing the visibility property, by adding an expression to look soomething like this :
=(Parameters!UserSelectedDate.Value=Fields!MONT.Value)
But that gives me an entire blank space for the Change column like this :
But I do, not want to see the blank space. I would like to remove the column completely.
Please let me know if it is possible.
I don't know, why it shows blank space, but here is how I handled this problem:
Choose "column visibility" property of column "Change"
Then I added expression for hiding column: =IIF(Month(Fields!Date.Value)=Parameters!UserSelectedDate.Value,True,False)
And when I select report parameter to 1 and preview the report, it hides Change column for month 1:
This answer works only for matrixed (varied count) columns.
But in all reports client want to group report data dynamicly and select column that one want to see.
So if I have matrix for example with columns -
[Store] [Good] [Amount Jan] [Amount Feb].... [Amount Dec]
I can hide any column with Amount but If I right click on column Store - No option in menu- Column properties and option Column Visibility - Disabled. If apply visibility to cells - you'll see a blank space.
I've looked for an answer for this issue and was frustrated that I could not find any. Then I found a workaround for this issue, I decided to share this.
You have to create column groups for all columns, which you would like to Show/Hide. For this matter you have to take or create one or more attributes in you ResultSet, which contain a constant value, so that the columns will not be later propagated.
After you created a new Column Group (as Adjacent Before/After)
you can put there the columns, which you like to Hide/Show.
After that you can use the property "Column visibility". It works just fine for me.