Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem is in your calculated measure. You are using .CurrentMember and ClosingPeriod without a specific member reference which implies a call to .CurrentMember. When you have set in the WHERE clause there is no "Current" member - there are multiple current members. Re-writting your MDX to something like the following should allow it to work with multiple members in the WHERE clause.</p> <pre><code>CREATE MEMBER CURRENTCUBE.[MEASURES].Ultimo AS NULL; SCOPE ([MEASURES].Ultimo); SCOPE ([Time].[Year - Month - Date].[All]); this = IIF ( (NOT [Measures].[LagerStk] = 0) ,Sum ( NULL:Tail(Existing [Time].[Year - Week - Date].[Date],1).item(0).item(0) ,[Measures].[LagerStk] ) ,NULL ); END SCOPE; SCOPE ([Time].[Year - Week - Date].[All]); this = IIF ( (NOT [Measures].[LagerStk] = 0) ,Sum ( NULL:Tail(Existing [Time].[Year - Month - Date].[Date],1).Item(0).Item(0) ,[Measures].[LagerStk] ) ,NULL ) ); END SCOPE; END SCOPE; </code></pre> <p>I am using SCOPE on the All members of the two dimensions, this should be fast that the out IIF and will also avoid one reference to .CurrentMember. I then replaced the <strong>ClosingPeriod()</strong> call with <strong>Tail(Existing [Time].[Year - Week - Date].[Date],1).item(0).item(0)</strong> what this does is to get the set of date members that exist in the current context, the Tail() call then gets the last on of these as a single member set and the .Item(0).Item(0) calls get the first member from the first tuple of that set.</p> <p>Obviously, not having access to your cube, I can't test any of this. The issue you reported in your comment could relate to either an incorrect reference to the All members (I may have a different naming format to the one in your cube) or it may be related to the IIF() statement. I'm not sure that the check for 0 is being evaluated in the correct context</p> <p>You could try testing without the IIF()</p> <p>CREATE MEMBER CURRENTCUBE.[MEASURES].Ultimo AS NULL;</p> <p>SCOPE ([MEASURES].Ultimo); SCOPE ([Time].[Year - Month - Date].[All]); this = Sum ( NULL:Tail(Existing [Time].[Year - Week - Date].[Date],1).item(0).item(0) ,[Measures].[LagerStk] ); END SCOPE;</p> <pre><code> SCOPE ([Time].[Year - Week - Date].[All]); this = Sum ( NULL:Tail(Existing [Time].[Year - Month - Date].[Date],1).Item(0).Item(0) ,[Measures].[LagerStk] ); END SCOPE; </code></pre> <p>END SCOPE;</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload