How to get Distinct Count of Products across two dimensions

Hi,
I have two dimensions, Item and Presentations. I need to get distinct count of products for IMD_Id + Merc_Pres_Id. IMD_Id is the lowest member in Item and Merc_Pres_Id is lowest in Presentation. My MDX query is given below but when I apply filters to
slice it, it does not work and does not give right count. It always gives the count for all.
/* Last Year Demand - Demand for 12 months back of selected months */
With
Member [Measures].[LYDemand]
as
Sum(
Generate(
EXISTING[All Date].[Fiscal Month Name].[Fiscal Month Name].Members,
{parallelperiod([All Date].[Fiscal Month Name].[Fiscal Month Name], 12
,[All Date].[Fiscal Month Name].CurrentMember)}
,[Measures].[Proj Demand]
/* Last to last Year Demand - Demand for 24 back of selected months */
Member [Measures].[LLYDemand]
as
Sum(
Generate(
EXISTING[All Date].[Fiscal Month Name].[Fiscal Month Name].Members,
{parallelperiod([All Date].[Fiscal Month Name].[Fiscal Month Name], 24
,[All Date].[Fiscal Month Name].CurrentMember)}
,[Measures].[Proj Demand]
/* Current Year Active Products */
Member [Measures].[CYCount]
as
CASE
WHEN
[Measures].[Proj Demand] > 0
THEN
DistinctCount(Existing(([All Items].[IMD Id].[IMD Id],[All Merchandise Presentations].[Merch
Pres Key].[Merch Pres Key])))
ELSE
NULL
END
/* Last year Active Products */
Member [Measures].[LYCount]
as
CASE
WHEN
[Measures].[LYDemand] > 0
THEN
DistinctCount(([All Items].[IMD Id].[IMD Id],[All Merchandise Presentations].[Merch Pres Key].[Merch Pres
Key], [All Items].[Style Name].CurrentMember, (StrToMember('[All Date].[Fiscal Month Name].&[201401]',CONSTRAINED).Lag(12)
: StrToMember('[All Date].[Fiscal Month Name].&[201411]',CONSTRAINED).Lag(12))))
ELSE
NULL
END
/* Last to last Year Active Products */
Member [Measures].[LLYCount]
as
CASE
WHEN
[Measures].[LLYDemand] > 0
THEN
DistinctCount(([All Items].[IMD Id].[IMD Id],[All Merchandise Presentations].[Merch Pres Key].[Merch Pres
Key], [All Items].[Style Name].CurrentMember, (StrToMember('[All Date].[Fiscal Month Name].&[201401]',CONSTRAINED).Lag(24)
: StrToMember('[All Date].[Fiscal Month Name].&[201411]',CONSTRAINED).Lag(24))))
ELSE NULL END
SELECT
[Measures].[CYCount], [Measures].[LYCount], [Measures].[LLYCount],
[Measures].[Proj Demand],[Measures].[LYDemand],[Measures].[LLYDemand]
ON
COLUMNS,
Non
Empty([All Items].[Demand Center Name].[Demand Center Name], [All Items].[Style Name].[Style Name])
ON ROWS
FROM
(SELECT (StrToSet('[All Items].[Style].[ALL]'))
ON COLUMNS
FROM
(SELECT (StrToSet('[All Items].[Demand Center].[ALL]'))
ON COLUMNS
FROM
(select (STRTOSET('[All Items].[Merch Group].&[MG-110]'))
on Columns
FROM
(SELECT (StrToSet('[All Merchandise Presentations].[Merch Pres Chnl Dkey].&[MPC-1]'))
ON COLUMNS
From
[FMI Forecasting]
WHERE {strToMember('[All Date].[Fiscal Month
Name].&[201401]',CONSTRAINED) :
StrToMember('[All Date].[Fiscal Month Name].&[201411]',CONSTRAINED)}
Requirements are as follows:
1. Distinct Count should not include products where Proj Demand is 0, when I am using Filter function to remove products with 0 demand, query is really slow and execution time goes up from 35- 40 secs to 8-9 Minutes.
2. When we apply filter (parameters) Distinct Count should be in the context of filters( which are mentioned in the select statement like Style, Demand Center and Merch Group). Currently after applying filters count does not change.
Thanks for help.

Hi Skd78,
Thank you for your question. 
I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
Thank you for your understanding and support.
Regards,
Charlie Liao
TechNet Community Support

Similar Messages

  • Distinct Count Measure Total in Two Dimensions

    I have a report that pulls data Site and then drills down to User for Content Usage for Six Months. These are separate dimensions in the cube. I have a DistinctContent Measure that pulls for both Site and User appropriately when I use separate queries but it
    is at the lowest level which is User. A sum of DistinctContent at the Site level is not appropriate - it needs to be the DistinctContent for the Site, and then drill down to the DistinctContent for User.
    Aggregate cannot be used because there are filters on the report, and they have to be there for various reasons.
    I've tried Lookup but it only looks up for one field. Multilookup doesn't work either. 
    I've tried a drill down to a subreport so that the initial dataset would be for Site, and then the subreport is for User and uses a different dataset, but you cannot merge the cells so
    that the subreport fits nicely under the top level.  
    How do I get the DistinctCount for the top level, Site?  
    I'm currently working on creating a cube that will only count the distinct content by site and then combine the two cubes as a virtual cube as a workaround but I'm not sure of the full implications of a virtual cube.   I feel like I'm missing something
    because this seems to be something that everyone must need at some point right?  
    I'm beating my head against a wall.  Thanks so much to anyone who can help out.  I'm hitting the deadline, and everyone is stressing out because I've been working on this one issue for days and I'm the everything IT person, so other things are slipping.
    Here is
     (the abbreviated version of) the query:
    SELECT
    NON EMPTY
    {[Measures].[Distinct Content]} ON COLUMNS
    ,NON EMPTY
    Filter
    ([Site].[by Type].[Site].ALLMEMBERS
    ,[Measures].[Views] > 0)*
    Filter
    ([User].[by Type].[User].ALLMEMBERS,
    [Measures].[Views] > 0
    [Time].[Month Year].[Month Year]
    DIMENSION PROPERTIES
    MEMBER_CAPTION
    ,MEMBER_UNIQUE_NAME
    ON ROWS
    FROM
    SELECT
    {[Content].[by Domain Type Item].[Type].&[3]&[1]&[Art]} ON COLUMNS
    FROM [Cntnt]
    Here is a picture of the report currently.  Unique Articles is the measure I'm having issues with and you can see at the top level is the site name, and below that the user.
    Thanks so much to anyone who can help me out.  I really, really appreciate it. 
    Julia

    Hi Julia,
    Thank you for your question. 
    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
    Thank you for your understanding and support.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to get Distinct Values from Answers

    Hi,
    How to get Distinct values from answers, i've tried to put some functions on it.
    Thanks,
    Malli

    Malli,
    Are you trying to fetch data from Dimension Attr OR Fact Measures? Did you try the advance tab - > Advanced SQL Clauses - > Check this box to issue an explicit Select Distinct.

  • How to get attendies count for a calendar list in sharepoint 2013?

    Hi everybody,
    I am using calendar list in SharePoint 2013 for my project.
    Could please tell me how to get the count of attendees using SP Designer or OOTB calculated field.
    Because I want to display the fields like
    TOTAL SEATS =20
    Attendees= Need count
    Avail seats= total - Attendees count.
    In that way I want to show information about availability seats for training session.
    Regards,
    Dhayanand

    Hi Dhaya
    Please refer the links.Hope it helps :-)
    http://social.msdn.microsoft.com/Forums/en-US/b8677dc5-3eb1-4bdc-92f2-f57201bfabb1/field-that-counts-attendees?forum=sharepointcustomizationprevious
    http://sharepoint.stackexchange.com/questions/54253/use-count-related-column-value-as-int-in-a-sp-designer-workflow

  • Multi Mapping : How to get Message count after splitting

    Hi all,
    I am following below blog.
    /people/narendra.jain/blog/2005/12/30/various-multi-mappings-and-optimizing-their-implementation-in-integration-processes-bpm-in-xi
    Can any body please tell me how to get the count of messages generated after splitting in the message mapping.. I have created the message data type but not aware what is needed to be done.
    Thanks and best regards,
    Kulwant Singh

    Multi mappings r done in order to split the messages to the number of messages required by the user. So for 1:N mapping, the details about "N" is based on ur requirement. So its not like - when u split, any number of message could get created. The count would be dependent on u.
    Regards,
    Prateek

  • How to get change date in Production Order ?

    Dear Friends,
    I want to know it, how to get change date in Production Order "Administration-TAB".
    F1-Help, It is displayed with "Change date for Order Master". and Structure table "CAUFVD".
    But, CAUFVD is not Transp. Table.
    Which table should I read ?
    Thanks in advance
    Yamazaki-H

    Dear Friend
    Thank you for an answer.
    It was settled.
    Best regards.

  • How to get file count in variable?

    dear all,
    how to get file count in variable?
    regards
    Naseer

    Hi Nazeer ,
    It wont take much time .. so simple :- )
    Create one os comand step
    ( for unix) Use
    wc -l filename.txt > someoutputfile.txt
    Now the number of lines in your file will be there in the output file ( someoutputfile.txt )
    Step2 :-
    Now use Cezar's logic to fetch the variable value ( file count ) from the output file .. ( select value for a variable from a file )
    This will not take eeven a second to finish the job.
    Regards,
    Rathish A M

  • How to get Page Count of pdf in Document library in EventHandler

    Hi,
    How to get Page Count of pdf in Document library once uploaded has been done and i would like to update the page count value in document library column of the corresponding file.
    I should achieve it in Event handler.
    Which even should i use, either ItemAdded or "ItemUpdated "?
    Thanks & Regards
    Poomani Sankaran.

    Hello,
    If you are looking for file download or view count then event handler will not work. You need to enable the analytic report to your site. Once you enable it then you can see the report within a browser or you can also create custom webpart to show count
    of specific file.
    http://blogs.msdn.com/b/ecm/archive/2010/05/03/web-analytics-in-sharepoint-2010-insights-into-reports-and-metrics.aspx
    http://sharepoint.stackexchange.com/questions/34611/count-of-files-under-a-folder-in-a-document-library
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Sql query to get distinct count

    Hi
    I use SQL Server Management Studio
    can I have a sql query to get count as shown below against  each month column and name column to get distinct count.
    for example if there is two rows with the same date period and same name then the count should be one in first row and zero in the next row of the same data.
    Table Name: Table1
    Column: Month, Name
    Month
    Name
    Count
    12/1/2012 0:00
    AK
    1
    12/1/2012 0:00
    AK
    0
    12/1/2012 0:00
    AB
    1
    1/1/2013 0:00
    AK
    1
    1/1/2013 0:00
    AK
    0
    1/1/2013 0:00
    AB
    1
    3/1/2013 0:00
    AA
    1
    3/1/2013 0:00
    AK
    1
    3/1/2013 0:00
    AK
    0
    6/1/2013 0:00
    AA
    1
    6/1/2013 0:00
    AK
    1
    6/1/2013 0:00
    AK
    0
    9/1/2013 0:00
    AA
    1
    9/1/2013 0:00
    AK
    1
    9/13/2013 0:00
    AK
    1
    10/1/2013 0:00
    AA
    1
    10/1/2013 0:00
    AK
    1
    10/1/2013 0:00
    AK
    0

    Hi,
    Thanks for the query but this query gives the total count like shown below
    if see the second row in the below table AK for 2012-12-1 gives total count as 2 but need the query to show the first row as 1 and there after 0
    query result
    Month name cnt
    2012-12-01 00:00:00.000 AB 1
    2012-12-01 00:00:00.000 AK 2
    2012-12-01 00:00:00.000 AK 2
    2013-01-01 00:00:00.000 AB 1
    2013-01-01 00:00:00.000 AK 2
    2013-01-01 00:00:00.000 AK 2
    2013-03-01 00:00:00.000 AA 1
    2013-03-01 00:00:00.000 AK 2
    2013-03-01 00:00:00.000 AK 2
    2013-06-01 00:00:00.000 AA 1
    2013-06-01 00:00:00.000 AK 2
    2013-06-01 00:00:00.000 AK 2
    2013-09-01 00:00:00.000 AA 1
    2013-09-01 00:00:00.000 AK 1
    2013-09-13 00:00:00.000 AK 1
    2013-10-01 00:00:00.000 AA 1
    2013-10-01 00:00:00.000 AK 2
    2013-10-01 00:00:00.000 AK 2

  • How about get item count of table in formGroup.vm

    JHeadstart Team:
    I want change maxColumns=" 1" or" 2" by item count of table .but I do not know how about get item count of table .
    #if (${JHS.current.group.columns} > 10)
    #set ($majin = 2)
    #else
    #set ($majin = 1)
    #end
    <af:panelForm rows="1" maxColumns="$majin" width="${JHS.current.group.formWidth}" id="${JHS.current.group.shortName}FormItems">
    majin
    #FORM_ITEMS()
    </af:panelForm>

    You can do this using the following syntax:
    #if (${JHS.current.itemContainer.items.size()}>10)
    maxColumns="2"
    #else
    maxColumns="1"
    #end
    Steven Davelaar,
    Jheadstart Team

  • How to copy data in ASO cube across two scenario's?

    How to copy data in ASO cube across two scenario's?

    There are multiple ways to do it.
    How is the source scenario sourced? If it is populated using load rules, then why don't change it in the rule itself?
    Regards
    Celvin

  • Substitution Variable across two dimensions

    Hello,
    I was wondering if we could define a single substitution variable across two dimensions. For instance, we have two dimensions Year (FY10,FY11,FY12, etc) and Period (QTR1, JAN, FEB, MAR, QTR2...)
    I understand we can define a range of values in a single subvar such as &period is Jan:Dec.
    However, given the above two dimensions we would like something like this Jan.FY10:Dec.FY13. I know this would be easier if years and months belonged to the same dimension but they are two different dimensions. So, essentially we want to define a single subvar involving two dimensions.
    Please let me know, if this is possible on Essbase 9.
    Thank you.
    Edited by: user10678366 on Sep 15, 2010 9:56 AM

    Thanks for all your responses. As Gary and Srinivas pointed out @XRANGE definitely works with a subvar with a few limitations;
    1. Cannot be used in a FIX statement
    2. For accurate months across different years, the order of the subvar should be FY11->FEB, FY13->DEC and not not FEB->FY11, DEC->FY13 since in my db, the Period dimension is DENSE and appears before the YEARS dimension in the outline.
    3. It works in a IF statement
    However one lingering issue I have is with a @PRIOR statement on conjunction with @XRANGE within my IF statement:
    Note: subvar &RANGE = FY11->FEB, FY13->DEC
    STAT1(
    IF(@ISMBR(@XRANGE(&RANGE)))
    IF(STAT1 = 20)
    STAT1 = @PRIOR(STAT1)
    ENDIF
    ENDIF
    The problem is STAT1 gets calculated accurately for all months for that year. However, all months the following year donot get calculated. So, essentially the BEGBALANCE (also at level 0) doesnt get calculated for the next year. Here an illustration of before and after:
              FY11     FY12     FY13
    Stat1     BegBalance               
         Jan     #MI     #MI     #MI
         Feb     #MI     #MI     #MI
         Mar     #MI     #MI     #MI
         Apr     #MI     #MI     #MI
         May     #MI     #MI     #MI
         Jun     20     #MI     #MI
         Jul     #MI     #MI     #MI
         Aug     #MI     #MI     #MI
         Sep     #MI     #MI     #MI
         Oct     #MI     #MI     #MI
         Nov     #MI     #MI     #MI
         Dec     #MI     #MI     #MI
    Stat1     BegBalance     #MI     #MI     #MI
         Jan     #MI     #MI     #MI
         Feb     #MI     #MI     #MI
         Mar     #MI     #MI     #MI
         Apr     #MI     #MI     #MI
         May     #MI     #MI     #MI
         Jun     20     #MI     #MI
         Jul     20     #MI     #MI
         Aug     20     #MI     #MI
         Sep     20     #MI     #MI
         Oct     20     #MI     #MI
         Nov     20     #MI     #MI
         Dec     20     #MI     #MI
    The expected result is:
    Stat1     BegBalance     #MI     20     20
         Jan     #MI     20     20
         Feb     #MI     20     20
         Mar     #MI     20     20
         Apr     #MI     20     20
         May     #MI     20     20
         Jun     20     20     20
         Jul     20     20     20
         Aug     20     20     20
         Sep     20     20     20
         Oct     20     20     20
         Nov     20     20     20
         Dec     20     20     20
    So, essentially though the @XRANGE takes into account BegBalance and calculates for each year based on prior year->dec, which is good. However, introducing the @PRIOR doesnt calculate BegBalance. Looks like I dont have any option other than using @MDSHIFT instead of @PRIOR when it comes to using @PRIOR with @XRANGE.
    Unless I am incorrectly using the @PRIOR statement with @XRANGE. Please suggest.

  • How to get the count of distinct customer in matrix?

    Hi,
    I want to get the count of distinct customer in matrix at the time of validation event.
    Thanks Regards,

    Hi,
    Please close the thread.by marking the correct answer
    regards,
    Prasad

  • "How to get distinct values of sharepoint column using SSRS"

    Hi,
        I have integrated sharepoint list data to SQL Server reporting services. I am using the below to query sharepoint list data using sql reporting services.
    <Query>
       <SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
       <Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
          <Parameters>
             <Parameter Name="listName">
                <DefaultValue>{GUID of list}</DefaultValue>
             </Parameter>
             <Parameter Name="viewName">
                <DefaultValue>{GUID of listview}</DefaultValue>
             </Parameter>
             <Parameter Name="rowLimit">
                <DefaultValue>9999</DefaultValue>
             </Parameter>           
          </Parameters>
       </Method>  
    <ElementPath IgnoreNamespaces="True">*</ElementPath>
    </Query>
    By using this query, I am getting a dataset which includes all the columns of sharepoint list. Among these columns, I wanted to display only 2 columns (i.e Region and Sales type) using chart. I have created a Region parameter but when I click preview, the drop down box is giving me all the repeatative values of region like RG1,RG1,RG1,RG2,RG2,RG2,RG2,RG3.......... I wanted to display only distinct values of Region parameter so that whenever end user select region from the parameter drop down, it will display the respective value of Sales type column.
    Also when I select only RG1 parameter, it is giving me a chart including the sales type of all the Regions. (it should display me only the sales type of RG1) How can I link these 2 columns so that they will display the values respectively.
              I would really appreciate if anyone can help me out with this.
    Thanks,
    Sam.

    Hi Sam,
    By code, the CAML language doesn’t have any reserved word (or tag) to set this particular filter to remove duplicate results.
    In this case, we could use the custom code to get distinct records.
    Here are the detailed steps:
    1.         Create a hidden parameter that gets all the records in one field.
    Note: Please create another dataset that is same of the main dataset. This dataset is used for the parameter.
    2.         Create a function that used to remove the duplicate records.
    Here is the code:
    Public Shared Function RemoveDups(ByVal items As String) As String
    Dim noDups As New System.Collections.ArrayList()
    Dim SpStr
    SpStr = Split(items ,",")
    For i As Integer=0 To Ubound(Spstr)
    If Not noDups.Contains(SpStr(i).Trim()) Then
    noDups.Add(SpStr(i).Trim())
    End If
    Next
    Dim uniqueItems As String() = New String(noDups.Count-1){}
    noDups.CopyTo(uniqueItems)
    Return String.Join(",", uniqueItems)
    End Function
    3.         Create another parameter that will be used for filtering the maindata.
    Please set the available value to be =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",")
    And the default value to be the value you what such as the first value:
    =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",").(0)
    4.         Go to the main dataset. Open the property window of this dataset.
    5.         In the “Filters” tab, set the filter to be:
    Expression: <The field to be filter>
    Operator: =
    Value: =Parameters!Region.Value
    The parameter “Region” should be the parameter we created in the step3.
    Now, we should get distinct values of SharePoint columns.
    If there is anything unclear, please feel free to ask.
    Thanks,
    Jin
    Jin Chen - MSFT

  • How to get the count of each minutes

    Oracle 10 DB
    Hi All
    I using this query to get the count of records fetched by the concurrent program per min,
    select count (distinct b.attribute2)
    from oe_order_headers_all a,oe_order_lines_all b
    where a.header_id=b.header_id
    and b.flow_status_code ='AWAIT_QUINTIQ_BOOK'
    and to_Char(b.last_update_date,'DD-MON-YYYY HH24:MI:SS') between '19-JAN-2011 02:00:01' AND
    '19-JAN-2011 02:00:02'
    This is used to get the count of records fetched at one mins
    How to find the count of last 10 mins ie 1 mins count 2.00 to 2.10
    Thanks & Regards
    Srikkanth.M

    Try this:
    SELECT TRUNC(b.last_update_date, 'mi') time_mins, COUNT(DISTINCT b.attribute2)
    FROM   oe_order_headers_all a,
           oe_order_lines_all b
    WHERE  a.header_id = b.header_id
    AND    b.flow_status_code = 'AWAIT_QUINTIQ_BOOK'
    AND    b.last_update_date >= to_date('19/01/2011 02:00:00', 'dd/mm/yyyy hh24:mi:ss')
    AND    b.last_update_date < to_date('19/01/2011 02:10:00', 'dd/mm/yyyy hh24:mi:ss')
    GROUP BY TRUNC(b.last_update_date, 'mi');I'm not sure why you're bothering with the join to the oe_order_headers_all table, since you're not referencing that in the where clause or the selected columns list. I think you could probably do away with it.
    I've changed your code to take the last_update_date and truncate it to the minute level, and added that as a column, so you can see which count goes with which minute. Obviously, this has to be in the group by.
    I've also changed your date comparisons so that you're actually comparing dates to dates, rather than strings to strings - why would you deliberately take information away from the optimizer? Oracle does not treat strings the same as dates, and forcing it to use strings rather than dates could lead you to have a vastly differing execution path, which will most likely be less performant.
    Not to mention, coding like that leads you to assume that you can compare dates in strings without any problems, and that is just not the case. '19-FEB-2011' is counted as being earlier than '19-JAN-2008', as strings sort alphabetically.

Maybe you are looking for