I currently try to build a google treemap chart in IcCube. Do I do this using a Multi Level dimension and defining every Level of drilldown separately (as shown
here and here), everything works fine.
What I would like to do is using a Parent/Child dimension and telling the treemap, just to go down this hierarchy when drilling into the treemap chart.
Is that possible?
Here is the (not working) MDX I used, where [categories] is the Parent/Child dimension:
WITH
MEMBER [category_name] as [categories].[categories].currentmember.name
SELECT
{[category_name],[Measures].[count_clicks]} on 0,
non empty [categories].[categories] on 1
FROM
[Cube]
Treemap is a tricky visualization. You need to define the two first columns as defining the parent/child relation. For example :
'Global', null
'America', 'Global'
'Europe', 'Global'
'Brazil', 'America'
The first column is by construction the Axis(1) name, so the seconds has to be the name of the parent and not the name of the member. Something like :
MEMBER [parent_name] as IIF( [categories].[categories].currentmember is [categories].[categories].[ALL],
NULL,
[categories].[categories].currentmember.parent.name )
That you can use as :
WITH
MEMBER [parent_name] as IIF( [categories].[categories].currentmember is [categories].[categories].[ALL],NULL,[categories].categories].currentmember.parent.name )
SELECT
{[parent_name],[Measures].[count_clicks]} on 0,
non empty [categories].[categories] on 1
FROM
[Cube]
This should work better.
Hope it helps.
After struggling for a while with my own data, I took the IcCube example of the parent/child Dimension (http://www.iccube.com/support/documentation/user_guide/schemas_cubes/dim_parentchild.php). Then I tried your example:
WITH
MEMBER [parent_name] as IIF( [dim (ALL)].[Hierarchy].currentmember
is [dim (ALL)].[Hierarchy].[ALL],'',
[dim (ALL)]. [Hierarchy].currentmember.parent.name )
SELECT
{[parent_name],[Measures].[value]} on 0,
non empty [dim (ALL)].[Hierarchy] on 1
FROM
[Cube]
(The NULL value had to be replaced by '')
The first dimension works, but if I try to drill into the map, the system tells me, that there is no row with id 'World'. Do you have any ideas, how to fix that?
EDIT:
After using real names in the parent/child dimension instead of ids (child: Spain; parent: Europe, value: 3) and replacing [dim (ALL)].[Hierarchy] with [dim (ALL)].[Hierarchy].members() in the code, I got a treemap working so far:
WITH
MEMBER [parent_name] as IIF( [dim (ALL)].[Hierarchy].currentmember
is [dim (ALL)].[Hierarchy],'',
[dim (ALL)].[Hierarchy].currentmember.parent.name )
SELECT
{[parent_name],[Measures].[value]} on 0,
non empty [dim (ALL)].[Hierarchy].members() on 1
FROM
[Cube]
Now after drilling down to the next level, the is an error message 'failed to find row with id "Europe"'. And I added a 3 Level into my data (child: Madrid; parent: Spain, value: 5), but I am unable to go to this level. Clicking on "Spain" doesn't change anything.
Related
I have an MDX issue that I really don't understand with a 5 level hierarchy "SEGMENTATION" : AFFAIRE/NIVEAU 1/ NIVEAU 2/NIVEAU 3/NIVEAU 4
I want to compare "NIVEAU 1" sub-levels weight to "Niveau 1".
For instance, I want to know for each 'NIVEAU 3' members its contributions part for its "NIVEAU 1".
I've tried a bunch of things, but nothing works properly. I don't get the trick and is stucked to :
WITH MEMBER [Measures].[TEST] AS'
iif(ISEMPTY(([Segmentation].[Niveau1], [Measures].[Total])) OR ([Segmentation].[Niveau1],[Measures].[Total]) = 0
, NULL
,[Measures].[Total] / ([Segmentation].[Niveau1], [Measures].[Total])
)'
SELECT NON EMPTY { [Measures].[TEST],[Measures].[Total]} ON COLUMNS
, NON EMPTY { [Segmentation].[Niveau2]}
ON ROWS FROM ( SELECT ( { [Segmentation].[Niveau1].&[8589934592]&[1|DESC111] } ) ON COLUMNS FROM [CUBE]) // Only one "Niveau 1" focus
And I get :
<Niveau 2> TEST Total
SF - C... #Error 25143658
SF - M... #Error 1638913,5
ZZZ ... #Error 90468628
#Error : The EqualTo function expects a string or numeric expression for argument 1. A tuple set expression was used.
The expected result is :
<Niveau 2> TEST Total
SF - C... 21,44% 25143658
SF - M... 1,40% 1638913,5
ZZZ ... 77,16% 90468628
21,4% = 25143658/(25143658+1638913,5+90468628)
What's wrong with my MDX?
Is there a mistake among the dimension or hierarchy set up?
Tuples are written as comma separated lists of members. What you have is a dimension.
Try
[Segmentation].CurrentMember.Parent
Instead of
[Segmentation].[Niveau1]
On your measure definition.
[EDIT] As mentioned in a comment, the goal is a solution that works on all levels. The solution is to use
Ancestor( [Segmentation].CurrentMember, [Segmentation].[Niveau1] )
in the Tuple used in the custom measure definition.
Thanks to nsousa, I'm now using :
WITH MEMBER [Measures].[Total Niveau1] AS'
iif([Segmentation].CURRENTMEMBER.level.ordinal>=2
,(Ancestor([Segmentation].CurrentMember,[Segmentation].[Niveau1] ),[Measures].[Total])
,([Segmentation].CURRENTMEMBER, [Measures].[Total])
)
'
MEMBER [Measures].[TEST] AS'
DIVIDE([Measures].[Societe],[Measures].[Total Niveau1])
',FORMAT_STRING = 'Percent'
SELECT NON EMPTY { [Measures].[TEST],[Measures].[Societe],[Measures].[Total]} ON COLUMNS
, NON EMPTY { [Segmentation].[Niveau3]}
ON ROWS FROM [CUBE]
maxDebt - it is column with formula.
lastDebt - it is column with data.
I tried to write maxDebt formula like this:
if(
prop("lastDebt") == 0,
0,
if(
prop("lastDebt") > prop("maxDebt"),
prop("lastDebt"),
prop("maxDebt")
)
)
And notion ask me error: "Property maxDebt creates a circular dependency."
How to resolve this task differently?
I am building a survey form through KoboToolbox. The web forms are Enketo based. I have some questions of the following type (before comma is first column and first row is data titles in XLSform format):
type, name
begin_group, group_farmexpenses_q5
note, group_farmexpenses_q5_note
integer, group_farmexpenses_q5_p1
text, group_farmexpenses_q5_column_1
end_group,
begin_group, group_farmexpenses_q5_1
note, group_farmexpenses_q5_1_note
integer, group_farmexpenses_q5_1_p1
text, group_farmexpenses_q5_1_column_1
end_group,
What i want to do is apply if statement for the integer values inside these two groups, however I get error. Here is what I do to apply if-statement :
if(${group_farmexpenses_q5_p1}=999, 0, ${group_farmexpenses_q5_p1})
if(${group_farmexpenses_q5_1_p1}=999, 0, ${group_farmexpenses_q5_1_p1})
since the above are calculate statements and each one is referred to as "expense1" and "expense2"
i then just add them
${expense1} + ${expense2}
I get error message:
if({group_farmexpenses_q5_1_p1} = 999, 0,
/model/instance[1]/data/group_wx0mk24/group_farmexpenses_q5_1/group_farmexpenses_q5_1_p1
), message: The expression is not a legal expression. (line:
undefined, character: undefined)
Any ideas how to fix this? I think there should be an easy fix but I don't know much about XLSform structures.
Proposed solution through online search for #Ziaw. Instead of first conditioning and then adding, both can be done in one step:
calculated data field compute this
if(${fexp_q1} = 999, 0, ${fexp_q1}) + if(${fexp_q2} = 999, 0,
${fexp_q2})
Using iccube reporting V6,
I'm looking for a way to remove some levels from a hierarchy (visually) on a filter widget.
This is working on "standards" widgets
but when using a Filter widget, i can only set 1 level as member.
Ok, I found a solution. The issue with the Tree filter is that it's using the parentUnique name to build the tree. But this is something we can trick.
For a time hierachy with multiple levels let's build a Tree with the Year and Month (without quarters). For this we can use this MDX
WITH
FUNCTION __currMember() AS [Date].[Date].hierarchy.currentmember
FUNCTION __defMember() AS {[Date].[Date].allmembers}(0).hierarchy.currentmember
FUNCTION __descendant(_c) AS Tail( Filter( Axis(1) as t, isAncestor(t.currentmember, _c )),1 )(0)
FUNCTION __unName(_c) AS IIF( _c is NULL, NULL, _c.uniqueName)
MEMBER ic3Name AS __currMember().name
MEMBER ic3UName AS __currMember().uniquename
MEMBER ic3PName AS __unName( __descendant(__currMember() ))
MEMBER ic3Measure AS 0
MEMBER ic3IsSelected AS false
MEMBER ic3FilterName as [Measures].[ic3Name]
MEMBER ic3Key as __currMember().key
SELECT
{[Measures].[ic3Name],[Measures].[ic3UName],[Measures].[ic3PName],[Measures].[ic3Measure],[Measures].[ic3IsSelected],[Measures].[ic3FilterName],[Measures].[ic3Key]} ON 0,
__defMember() + Hierarchize([Date].[Date].[Year] + [Date].[Date].[Month]) ON 1
FROM [Cube]
It's the descendant() function that is doing the trick. You can change the function if it's not suiting your needs or it's too slow for something checking the levels. Note, the algo is O(N*N) on the axis, it's not great. But I think it should be generic.
With a bit of imagination and MDX you can do a bit whatever you'd like as for building the tree we're using the measures ( ON 0 axis ).
I have an employee parent-child hierarchy in a dimension called Employees which shows the managerial structure of an organisation. This hierarchy is [Employees].[Managerial].
There is another hierarchy that lists all the employees for an organisation. This is a single level hierarchy and it is [Employess].[All Employees].
I have a query that looks something like this:
With
Member measures.[FullTimeSalary] as measures.[Salary] * measures.[FullTimeFactor]
Select {measures.[FullTimeSalary]} on 0,
Non empty
{
[Employess].[All Employees].[All].Children
}
On 1
From MyCube
Where ([Time].[Month].&[201501])
Now if I expand the parent-child hierarchy (the [Employees].[Managerial] hierarchy) I can see each of the different levels of this structure( [Level 02], [Level 03], [Level 04], ect) and what I need to do now is create a new calculated measure called measures.[SupervisingManager] that brings back the currentmembers value at [Level 03] of the hierarchy.
I've tried
member measures.[SupervisingManager] as [Employees].[Managerial].[Level 03].currentmember.member_name
but that just returns "#Error" and using
member measures.[SupervisingManager] as [Employees].[Managerial].currentmember.member_name
returns that currentmember. I also experimented with
measures.[SupervisingManager] as [Employees].[Managerial].currentmember.parent.member_name
but the issue with this is that the currentmember can be located at any within the hierarchy. The only way I can think of doing this is to do a massive case statement, get the ordinal value of the current member and use the appropriate .parent.parent logic. Is there a neater way to do this?
Maybe something along these lines will help:
WITH
MEMBER measures.[FullTimeSalary] AS
measures.[Salary] * measures.[FullTimeFactor]
MEMBER measures.[SupervisingManager] AS
IIF
(
[Employees].CurrentMember.Parent.Level.Name = 'Level 03'
,[Employees].CurrentMember.Parent.Member_Caption
,'n/a'
)
SELECT
{
measures.[FullTimeSalary]
,measures.[SupervisingManager]
} ON 0
,NON EMPTY
{[Employess].[All Employees].[All].Children} ON 1
FROM MyCube
WHERE
[Time].[Month].&[201501];