MDX Scope returning NULL #VALUE - scope

I have been on this issue for the past 2 weeks and am getting bored of MDX and my work.
I have a scope script to override the figure coming from the source table for the following lines. 1. Pool Charge (2075) 2. Pool Compensation (2076)
SCOPE ([Measures].[Income Amount]);
SCOPE ([Income Caption].[Captions].&[2075],[Measures].[Income Amount]); //POOL CHARGE
this = [Measures].[Charge];
END SCOPE;
SCOPE ([Income Caption].[Captions].&[2076],[Measures].[Income Amount]); // POOL COMPENSATION
this = [Measures].[Compensation];
END SCOPE;
Screenshot of the sample reports.
I want to further manipulate those 2 lines in green: I want to sum-up other Pool Contribution entries and place it in MD LINE. Please note MDLine exclusive. The same goes to Pool Charge.
MD LINE Pool compensation = 'ASSET & INVESTMENT MANAGEMENT' + 'CORPORATE BANKING' + 'GENERAL DEFAULT' + 'INVESTMENT BANKING' + 'TREASURY AND GLOBAL MARKETS' Please note only Pool compensations and Pool charges.
All efforts been returning null or #VALUE.
Please help.
Many thanks.

What about?
Scope ([Income Caption].[Captions].&[2075],[Measures].[Income Amount]);
This = IIF(
[Something].[Something].CurrentMember is [Something].[Something].[MD LINE]
([Something].[Something].[All],[Measures].[Charge]),
[Measures].[Charge]
);
End Scope;
Replace Something with the corresponding dimension and hierarchy.

Related

Calculate the sum of capacity per category in a pivot table linked to 3 different tables-Excel

Hallo I'm new with DAX expressions and I'm getting trouble when i want to calculate a value depending on different categories in each registry of my DB and show the report in a pivot table.
I have 3 tables: Projects, Rates and Workers per Project.
I want to calculate the required capacity per worker depending in which role are, in which type of project are and in which stage(phase) of the project are.
With SUMX(Rates;Rates[Req. Capacity]) I'm getting the same value for all the workers in each role.
[Workers per Project][1]
[Projects][2]
[Rates ][3]
This is the result im looking for:
[Result wanted][4]
can someone help me to make it work ?
Thanks in advance ! :)
[1]: https://i.stack.imgur.com/ZtGgT.png
[2]: https://i.stack.imgur.com/5QObD.png
[3]: https://i.stack.imgur.com/B8RDH.png
[4]: https://i.stack.imgur.com/iKMrS.png
--Measure on Rates table
--Change semicolon for comma if needed
--Made in Excel because it was already running :)
Required Capacity :=
VAR RolesByCW = VALUES(WorkersPerProject[Role]) --CW(CurrentWorker)
VAR ProjectsIDByCW = DISTINCT(WorkersPerProject[Project])
VAR ProjectTypeByCWandProjectID=
CALCULATETABLE(VALUES(Projects[Type]);CONTAINSROW(ProjectsIDByCW;Projects[Project]))
RETURN
CALCULATE(
SUM(Rates[Req. Capacity]);
CONTAINSROW(RolesByCW;Rates[Role]);
CONTAINSROW( ProjectTypeByCWandProjectID;Rates[Type])
)

MDX - rewrite a query using scope

I have an MDX query
IIF
(
IsLeaf([PnL].[PnL_A].CurrentMember)
,
[Measures].[PnL - Plan] * [PnL].[Flag 5].CurrentMember.MemberValue
,Sum
(
[PnL].[PnL_A].CurrentMember.Children
,[Measures].[PnL- Plan (signed)]
)
)
What it does:
The whole thing represents profit and loss. Unfortunately, it is constructed in a way that there are two columns: value of a profit or loss, and flag in the other column.
So if the flag ([PnL].[Flag 5]) is set to -1, the value ([Measures].[PnL - Plan]) is a loss, if the flag is a 1 - the value is a profit. I can't change that.
The query finds leaves of the hierarchy (single deepest source of a profit or loss) and multiplies the flag with the value. For non-leaf members it just aggregates it's leaves.
My problem is that it works too slow - I wanted to rewrite this query using SCOPE but I have no idea how.
Since I have absolutely no idea on your cube structure, let's say your member structure is
Pnl-->Pnl_A-->NonLeaf-->Leaf
You could define scope as below -
CREATE MEMBER CurrentCube.[Measures].[ProfitOrLossValue] AS NULL;
//Current member is leaf and Flag5 is 1
SCOPE
(
[Measures].[ProfitOrLossValue],
[PnL].[Flag 5].&[1],
[PnL].[PnL_A].[Leaf].[All].CHILDREN
);
This = [Measures].[PnL - Plan];
END SCOPE;
SCOPE
(
[Measures].[ProfitOrLossValue],
[PnL].[Flag 5].&[-1],
[PnL].[PnL_A].[Leaf].[All].CHILDREN
);
This = ([Measures].[PnL - Plan] * -1);
END SCOPE;
//Current member is non-leaf
SCOPE
(
[Measures].[ProfitOrLossValue],
[PnL].[PnL_A].[NonLeaf].[All].CHILDREN
);
This = Sum
(
[PnL].[PnL_A].CurrentMember.Children,
[Measures].[PnL- Plan (signed)]
);
END SCOPE;
Hope it helps.

SSAS How to scope a calculated member measure to a number of specific members?

I'm trying to create a calculated member measure for a subset of a group of locations. All other members should be null. I can limit the scope but then in the client (excel in this case) the measure does not present the grand total ([Group].[Group].[All]).
CREATE MEMBER CURRENTCUBE.[Measures].[Calculated Measure]
AS (
Null
),
FORMAT_STRING = "$#,##0.00;-$#,##0.00",
NON_EMPTY_BEHAVIOR = { [Measures].[Places] }
,VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'Locations';
-----------------------------------------------------------------------------------------
SCOPE ({([Group].[Group].&[location 1]),
([Group].[Group].&[location 2]),
([Group].[Group].&[location 3]),
([Group].[Group].&[location 4]),
([Group].[Group].&[location 5])
}, [Measures].[Calculated Measure]);
// Location Calculations
THIS = (
[Measures].[Adjusted Dollars] - [Measures].[Adjusted Dollars by Component] + [Measures].[Adjusted OS Dollars]
);
END SCOPE;
It's as though the [Group].[Group].[All] member is outside of the scope so it won't aggregate the rest of the members. Any help would be appreciated.
Your calculation is applied after all calculations already happened. You can get around this by adding Root([Time]) to the scope, assuming your time dimension is named [Time]. And if you want to aggregate across more dimensions, you would have to add them all to the SCOPE.
In most cases when you have a calculation that you want too do before aggregation it is more easy to define the calculation e. g. in the DSV, e. g. with an expression like
CASE WHEN group_location in(1, 2, 3, 4) THEN
Adjusted_dollars - adjusted_dollars_by_comp + adjusted_os_dollars
ELSE NULL
END
and just make a standard aggregatable measure from it.
I've searched high and low for this answer. After reading the above suggestion, I came up with this:
Calculate the measure in a column in the source view table
(isnull(a,0) - isnull(b,0)) + isnull(c,0) = x
Add the unfiltered calculated column (x) to the dsv
Create a named calculation in the dsv that uses a case statement to filter the original calc measure CASE WHEN location IN ( 1,2,3)THEN xELSE NULLEND
Add the named calculation as measure
I choose to do it this way to capture the measure unfiltered first then, if another filter needs to be added or one needs to be taken off, I can do so without messing with the views again. I just add the new member to filter by to my named calculation case statement. I tried to insert the calculation directly into a named calculation in the dsv that filtered it as well but the calculation produced the incorrect results.

SSAS Cube calculation Scope with criteria

I need your help with a scope definition where the Goal is to create (in this case) a site = "TAI API", that is the aggregation of two other sites
"CPH API" + "US API" where product
in ([Product].[Manufacturing Family].&[BANT],[Product].[Manufacturing Family].&[BZNT],[Product].[Manufacturing Family].&[VANT]))
What I have done is creating the site as follow:
CREATE MEMBER CURRENTCUBE.[Order Company Group].[Parent].[All].[TAI API]
as [Order Company Group].[Parent].&[10440 - API]+[Order Company Group].[Parent].&[10240 - API]
, VISIBLE = 1 ;
Then I would like to define a scope for this site "TAI API", so that it works for any measure, but I am unsure what the next step is... I have tried something like this, but it doesn't work as intended:
SCOPE ([Order Company Group].[Parent].[All].[TAI API] ) ;<br/>
this = ([Measures].??<br/>
,([Product].[Manufacturing Family].&[BANT],[Product].[Manufacturing Family].&[BZNT],[Product].[Manufacturing Family].&[VANT]));<br/><br/>
END SCOPE;
The [Measures].?? is to indicate that I am not sure if this is needed or what to write...
Turns out I can do something like this
CREATE MEMBER CURRENTCUBE.[Order Company Group].[Parent].[All].[TAI API]
as [Order Company Group].[Parent].&[10440 - API]+[Order Company Group].[Parent].&[10240 - API]
, VISIBLE = 1 ;<br/><br/>
SCOPE ([Order Company Group].[Parent].[All].[TAI API]);<br/>
SCOPE([Product].[Manufacturing Family].[Manufacturing Family].members
- [Product].[Manufacturing Family].&[BANT]
- [Product].[Manufacturing Family].&[BZNT]
- [Product].[Manufacturing Family].&[VANT]
);<br/>
this = null;
<br/>
END SCOPE;
<br/><br/>
END SCOPE;
Thanks Thomas
You can use scope w/o any measures references:
At the very beginning (I just used my own DB with sample on standard Year-Month-Day dimension):
CREATE MEMBER CURRENTCUBE.[Create Date].[Create Date].[Month].&[201402].[20140200]
AS null,
VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'Data' ;
And than scope at the end:
SCOPE ([Create Date].[Create Date].[Month].&[201402].[20140200]);
THIS = SUM({[Create Date].[Create Date].[Day].&[20140214],[Create Date].[Create Date].[Day].&[20140228]});
END SCOPE;
This will work even with calculated measures with Descendants (e.g. ...Exists(Descendants([Create Date].[Create Date].[Year].&[2014],[Create Date].[Create Date].[Month],SELF_BEFORE_AFTER)...)
Please see this image. Is it expected result?
If so, you can just set first time NULL to this new member. And that in scope write
SUM([Order Company Group].[Parent].&[10440 - API],[Order Company Group].[Parent].&[10240 - API])
Hope it helps.

crm 2011 when update a field in account entity there is no change

Well, my problem is the follow. I create a entity. i call this new_logpuntossegmentacin that has a relation 1 to ∞ with account, when i put in the registration plugin message, create i hope that the follow code fill out the field puntosacumulados but nothing happens:
cli is a Account from a List
total is a Decimal
total = total1 + total2 + total3 + total4 + total5 + total6;
cli.new_puntosacumulados.Insert(i, total.ToString());
svcContext.UpdateObject(cli);
svcContext.SaveChanges();
i++;
if (!String.IsNullOrEmpty(total.ToString()))
{
tracingService.Trace("Response = {0}", total.ToString());
}
tracingService.Trace("Done.");
A couple of questions which may give a little more context:-
1) When you say nothing happens, do you mean that the value is not updated in the database or it doesn't appear updated on the form? If the latter then it may be when the plug in is firing (pre vs post).
2) Could you perhaps post the rest of the method as it may be useful to get some context on some of the other parameters, e.g. what is "i" iterating over here?
Thanks

Resources