MDX How to get total distict count and SUM of subgroups?

with
MEMBER Measures.[EmailCount] as IIF(ISEMPTY([Measures].[Tran Count]), 0 ,[Measures].[Tran Count])
MEMBER Measures.AdvGroupTotal as
SUM (
FILTER( EXISTING ([Dim IFA Details].[Parent Key].[Adviser Group].Members * [Dim Date].[Fiscal].[Fiscal Year].members )
, Measures.[Amount] > 100 )
, Measures.[Amount])
MEMBER Measures.[AdvGrpCount] as
distinctCOUNT(Existing([Dim IFA Details].[Parent Key].[Adviser Group].Members * [Dim Date].[Fiscal].[Fiscal Year].members))
member Measures.IncomePerEmail as Measures.AdvGroupTotal /Measures.[EmailCount]
member Measures.AvgIncomePerFirm as Measures.AdvGroupTotal/ Measures.AdvGrpCount
SELECT { [Measures].[Amount] , Measures.[EmailCount], Measures.AdvGroupTotal, Measures.[AdvGrpCount],
Measures.IncomePerEmail, Measures.AvgIncomePerFirm }
ON COLUMNS,
[Dim Date].[Fiscal Year].[Fiscal Year].ALLMEMBERS * [Dim Date].[Fiscal Quarter].[Fiscal Quarter].ALLMEMBERS *
Except( [Dim Income Range].[Hierarchy].[Range ID].Members , [Dim Income Range].[Hierarchy].[All].UNKNOWNMEMBER.UNKNOWNMEMBER )
on rows
FROM [Income and Emails Cube]
where
[Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14]
The query above returns :
How can I get Totals for AdvGroupTotal and AdvGroupCount for the year ?
In the above case I want to tally up 1586 + 67 + 155 + 12 + 1718 for AdvGroupCount, same applies for the corresponding
AdvGroupTotal figures.
Seems simple enough, but I seem unable to come up with a way around this.
Jon

I worked it out with the help of Simon from another forum.
Using a filtered set will get me the result required. It is however not very quick, so I probably should look into building it into the cube.
WITH SET [Filtered Groups] AS
( Filter (
{ [Dim IFA Details].[Parent Key].[Adviser Group] } *
{ [Dim Date].[Fiscal Year].CurrentMember },
[Measures].[Amount] > 100
MEMBER [Measures].[Annual] AS
Sum ( [Filtered Groups], Measures.[Amount] )
MEMBER [Measures].[Firm Count] AS
DistinctCount ( [Filtered Groups] )
MEMBER [Measures].[Avg Income Per Firm] AS
[Measures].[Annual] / [Measures].[Firm Count]
MEMBER [Measures].[Test] AS
Sum (
{ [Dim Date].[Fiscal Quarter].[Fiscal Quarter] } * { [Dim Income Range].[Hierarchy].[Range ID] } * { [Filtered Groups] },
[Measures].[Amount]
MEMBER [Measures].[TotalCount] AS
DistinctCount (
{ [Dim Income Range].[Hierarchy].[Range ID] } * { [Filtered Groups] }
MEMBER [Measures].[TotalAvg] as [Measures].[Test]/ [Measures].[TotalCount]
MEMBER [Measures].[Quarter] as [Measures].[Amount]
SELECT
{ [Measures].[Quarter], [Measures].[Annual], [Measures].[Firm Count], [Measures].[Avg Income Per Firm],
[Measures].[Test], [Measures].[TotalCount], [Measures].[TotalAvg] } ON COLUMNS,
[Dim Date].[Fiscal Year].[Fiscal Year].AllMembers * [Dim Date].[Fiscal Quarter].[Fiscal Quarter].AllMembers *
Except ( [Dim Income Range].[Hierarchy].[Range ID].Members, [Dim Income Range].[Hierarchy].[All].UnknownMember.UnknownMember )
DIMENSION PROPERTIES Member_Unique_Name, MEMBER_CAPTION
ON ROWS
FROM [Income and Emails Cube]
WHERE [Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14]

Similar Messages

  • How To Get Deleted Item Count and Associated Item Count And LastLogOn and LogOff Time For A Mailbox In Exchange Using EWS

    Using Powershell cmdlet i get  all the details..But i want to get these Details by using EWS Managed Api.Is It Possible to do???
    Powershell Cmdlet,
    Get-MailboxStatistics -Identity Username, Using this cmdlets all the details will get displayed.
    DeletedItemCount:5 //Here how this count comes.In My OutlookWebApp the deleteditems folder contains 13 items in it..But the count shows only 5.
    TotalDeletedItemSize:5.465 Kb//Even this value too does not match with DeletedItems Folder size in owa.
    AssociatedItemCount:12
    LastLogOnTime:11/11/11 12:43PM
    LastLogOff Time:11/11/11 2:43PM
    In EWS,
    By Looping through all folders i can get the total item count and total item size.Even i can get deleteditems  count .But that value does not match  With the powershell value.Even the TotalDeletedItemSize
    Doesnt match.
    Using EWS Managed Api ,Looping through folders i can get ItemCount,TotalitemSize,(DeletedItems,TotalDeleteditemSize(These TwoValues Does not match with values comes from powershell))
    Now how to get the Associated item count and lastlogoff and logon time using EWS managed Api.Is it Possible???
    And even y the deleteditems count and size values varies between EWS and powershell.

    What happens if you execute the below code?
    Get-MailboxFolderStatistics [email protected] | where {$_.FolderPath -like "/Deleted Items"}
    Refer this blog. You may get some dice
    http://exchangepedia.com/blog/2008/09/configuring-deleted-item-retention.html
    Regards Chen V [MCTS SharePoint 2010]

  • How to get total page count (in footer) for just a section?

    In Pages 08, I was able to put a total page count (for only a section) in the footer. However, when I tried doing the same thing in Pages 09, it keeps giving me a total page count for the entire document. I used the same settings for Pages 08 and 09, but 09 keeps giving me the total page count for the entire document. Does anyone know how I can make it work like it did in Pages 08? This is really annoying and preventing me from buying iWork 09 as I need this feature to work. Thanks in advance!

    As far as I know, the Pages '08 behavior was a bug.
    The Pages '09 Help states:
    Here are ways to work with information about a document:
    To add or change descriptive information about a document (author, title, comments, and keywords), click Inspector in the toolbar, click the Document button, and then click Info. Enter or change information in the fields in the pane.
    This information is searchable using Spotlight on computers with Mac OS X version 10.4 and later.
    _To display document statistics, such as number of words, pages, lines, paragraphs, sections, graphics, and characters in the document_, click Inspector in the toolbar, click the Document button, and then click Info.
    _A document’s word and page count_ are always visible at the bottom left of the window. To hide your document’s word count, choose Pages > Preferences, and then deselect “Show word count at window bottom.”
    If a range of text is selected, you can specify the extent of the displayed statistics by choosing Selection or Document from the Range pop-up menu in the Document inspector.
    This time it's clear that except if you select a chunk of text, word count and page count are global document 's properties.
    Yvan KOENIG (from FRANCE lundi 2 février 2009 11:48:56)

  • How to get total numbers and total price in query reports

    Hi,
    how to get total numbers and total price in query reports.for example:
    particular item is issued 3 times a week...I need total quantity of item issued
    my query...
    SELECT T0.[DocNum], T1.[ItemCode], T1.[Quantity], T1.[Price] FROM OIGE T0  INNER JOIN IGE1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[ItemCode]  Like '%%[%1]%%'  and  T1.[U_WOType]='[%0]'

    Hi,
    Try this:
    SELECT T1.[ItemCode], SUM (T1.[Quantity]) as [Total Quantity], SUM (T1.[Quantity] * T1.[Price]) as [Total Price] FROM OIGE T0  INNER JOIN IGE1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[ItemCode]  Like '%%[%1]%%'  and  T1.[U_WOType]='[%0]'
    Group By T1.[ItemCode]
    Beni.

  • How to get  visible row  count  in JTable ?

    I have one table which is added to one scroll pane. For example my table have total 1000 rows, but at a time only 20 rows should be visible to the scroll pane. And I want to scroll the rows and show only 20 at a time.When user scrolls JTable then next time he can view only 1 to 21, then 2 to 22, and so on. I want to know how to get that number which represents the visible row( in this case it is 20).So kindly help me how to get visible row count. Any help regarding this will be appriciated.
    Thanks and Regards,
    Sheetal

    how to get visible row count.First you need to get the viewport used by the scrollpane. Then you can use methods like getViewPosition() and getViewSize() to get information about the current postition of and size of the viewport.
    Then you can use the table method getRowAtPoint(). to determine the first and last visible row which can then be used to calculate the visible row count.
    When user scrolls JTable then next time he can view only 1 to 21, then 2 to 22, and so onThis is the default behaviour when a "block" scroll is done.
    However when you click on the arrow button on the scrollbar it will only scroll a single row. You could override the getScrollableUnitIncrement() method to return the value from the getScrollableBlockIncrement() method.
    However the user can still drag the scrollbar manually which would cause a problem. So you would also need to remove the MouseMotionListeners from the scrollbar to prevent this.

  • How to get file line count.

    Hey guys,
    How to get file line count very fast? I am using BufferedReader to readLine() and count. But when dealing with big file, say several GB size, this process will be very time consuming.
    Is there any other methods?
    Thanks in advace!

    What I'd do is you create an infofetcher, register a listener, implement gotMore() and have that scan for '\n'
    Some might suggest getting rid of the listener/sender pattern or use multiple threads to make ii faster. This might help a little, but only if your I/O is super-duper speedy.
    you are welcome to use and modify this code, but please don't change the package or take credit for it as your own work.
    InfoFetcher.java
    ============
    package tjacobs.io;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.Iterator;
    * InfoFetcher is a generic way to read data from an input stream (file, socket, etc)
    * InfoFetcher can be set up with a thread so that it reads from an input stream
    * and report to registered listeners as it gets
    * more information. This vastly simplifies the process of always re-writing
    * the same code for reading from an input stream.
    * <p>
    * I use this all over
         public class InfoFetcher implements Runnable {
              public byte[] buf;
              public InputStream in;
              public int waitTime;
              private ArrayList mListeners;
              public int got = 0;
              protected boolean mClearBufferFlag = false;
              public InfoFetcher(InputStream in, byte[] buf, int waitTime) {
                   this.buf = buf;
                   this.in = in;
                   this.waitTime = waitTime;
              public void addInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        mListeners = new ArrayList(2);
                   if (!mListeners.contains(fll)) {
                        mListeners.add(fll);
              public void removeInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        return;
                   mListeners.remove(fll);
              public byte[] readCompletely() {
                   run();
                   return buf;
              public int got() {
                   return got;
              public void run() {
                   if (waitTime > 0) {
                        TimeOut to = new TimeOut(waitTime);
                        Thread t = new Thread(to);
                        t.start();
                   int b;
                   try {
                        while ((b = in.read()) != -1) {
                             if (got + 1 > buf.length) {
                                  buf = IOUtils.expandBuf(buf);
                             int start = got;
                             buf[got++] = (byte) b;
                             int available = in.available();
                             //System.out.println("got = " + got + " available = " + available + " buf.length = " + buf.length);
                             if (got + available > buf.length) {
                                  buf = IOUtils.expandBuf(buf, Math.max(got + available, buf.length * 2));
                             got += in.read(buf, got, available);
                             signalListeners(false, start);
                             if (mClearBufferFlag) {
                                  mClearBufferFlag = false;
                                  got = 0;
                   } catch (IOException iox) {
                        throw new PartialReadException(got, buf.length);
                   } finally {
                        buf = IOUtils.trimBuf(buf, got);
                        signalListeners(true);
              private void setClearBufferFlag(boolean status) {
                   mClearBufferFlag = status;
              public void clearBuffer() {
                   setClearBufferFlag(true);
              private void signalListeners(boolean over) {
                   signalListeners (over, 0);
              private void signalListeners(boolean over, int start) {
                   if (mListeners != null) {
                        Iterator i = mListeners.iterator();
                        InputStreamEvent ev = new InputStreamEvent(got, buf, start);
                        //System.out.println("got: " + got + " buf = " + new String(buf, 0, 20));
                        while (i.hasNext()) {
                             InputStreamListener fll = (InputStreamListener) i.next();
                             if (over) {
                                  fll.gotAll(ev);
                             } else {
                                  fll.gotMore(ev);
    InputStreamListener.java
    ====================
    package tjacobs.io;
         public interface InputStreamListener {
               * the new data retrieved is in the byte array from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
              public void gotMore(InputStreamEvent ev);
               * reading has finished. The entire contents read from the stream in
               * in the buffer
              public void gotAll(InputStreamEvent ev);
    InputStreamEvent
    ===============
    package tjacobs.io;
    * The InputStreamEvent fired from the InfoFetcher
    * the new data retrieved is from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
    public class InputStreamEvent {
         public int totalBytesRetrieved;
         public int start;
         public byte buffer[];
         public InputStreamEvent (int bytes, byte buf[]) {
              this(bytes, buf, 0);
         public InputStreamEvent (int bytes, byte buf[], int start) {
              totalBytesRetrieved = bytes;
              buffer = buf;
              this.start = start;
         public int getBytesRetrieved() {
              return totalBytesRetrieved;
         public int getStart() {
              return start;
         public byte[] getBytes() {
              return buffer;
    ParialReadException
    =================
    package tjacobs.io;
    public class PartialReadException extends RuntimeException {
         public PartialReadException(int got, int total) {
              super("Got " + got + " of " + total + " bytes");
    }

  • How to get the column count at the bottom of the column

    Hi Friends,
    How to get the column count at the bottom of the column
    Thanks
    Raj

    You mean row count? Add another column, click on the fx button and type RCOUNT(1).
    If you want just the total you can make it MAX(RCOUNT(1)), hide this column and then add a Narrative View after your report and enter "Total Number of Records: @n" where "n" represents what order your column is from the left side.

  • How to get total in ALV report in same Internal table?

    Data : Begin of it_data,
            kunnr type kunnr,
            name1 type name1,
            amt1  type btrt01, " CURR 15,2
           end of it_data.
    loop at it_data into wa_data
    endloop.      
    Hello friends,
    I am developing one ALV report with 20 rows.
    I have filled one internal table with some fileds like amount.
    I want to get total of all amount1 in AMT1 field.
    So, How to get total of amount in same internal table in ALV report ?
    It is ok if i get duplicate rows in internal table.
    Points 'll be awarded soon.
    Regards,
    NVM

    Hi Ronny,
    the alv output will display the sum at the last row.
    for this functionality u have do this logic.
    data: lw_fcat type slis_fieldcat_alv.
    data: lt_fcat type slis_t_fieldcat_alv/
    wa_fcat-fieldname = 'AMT1'.
    wa_fcat-tabname = 'ITAB'.
    wa_fcat-do_sum = 'X'.
    append wa_fcat to lt_fcat.
    and then pass it to reuse_alv_grid_display function,
    regards,
    Santosh Thorat

  • How to get total number of days

    Hi All,
    how to get total number of days , for example if month eq 05 then need to get total number of days until MAY 31.
    and how to get total number of days in a month.
    Thank You,,
    Sriii..

    Hi Sridhar,
    Pls Try to search before posting general questions.
    Try this,
    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
        EXPORTING
          i_datum_bis                   = p_lv_date1
          i_datum_von                   = p_lv_date2
       IMPORTING
         e_tage                        = p_e_date_difference
       EXCEPTIONS
         days_method_not_defined       = 1
         OTHERS                        = 2
      IF sy-subrc  0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Regards,
    Sunil kairam.

  • How to get the row Count of a ResultSet

    How to get the row Count of a ResultSet

    Hi
    I'v tried rennie1's way ,but I only get zero,my code is:
    rs.executeQuery("select count(*) from t_test");
    if (rs.next()) int rowCount=rs.getInt(1);
    I also tried barni's way ,but the method rs.last() and rs.beforeFirst() throw a same Exception
    I tried another way,the code is:
    while rs.next(){
    // Do nothing ,just move the cursour to the last row
    int rowCount=rs.getRow()
    However,the rowCount still equal zero
    Any help would be greatly apprecite!
    note:
    I get connection by DataSource's JNDI name from client, the Server is Weblogic Server 6, the DBMS is Oracle.

  • How to get total of any field in sapscript?

    Hello ,
    i m making sapscript...
    How to get total of any field in sapscript?

    Hi
    Yes, you can define a variabe in your print program and pass it to the SAPScript.
    LIKE:
    Define L_SUM in the Global data.
    DATA: L_SUM TYPE BSEG-DMBTR.
    LOOP AT ITAB.
    L_SUM = L_SUM + ITAB-AMOUNT.
    ENDLOOP.
    CALL FUNCTION 'WRITE_FORM'
    WINDOW = 'MAIN'
    ELEMENT = 'TOTAL'.
    Now, in your SAPScript, create a text element in MAIN window
    /E TOTAL
    Total,, &L_SUM&.
    Go through below link
    http://sap-img.com/sapscripts/sapscript-how-to-calculate-totals-and-subtotals.htm
    Regards,
    Chandru

  • How to get total at each hierarchy

    Hello Gurus,
    Does anybody know how to get total at each  level.
    I mean, if I have the following structure...
    Level 1
    Level 2
    Level 3
    Level 4
    Level 5
    At level 5 we have the following calculation
    Volume      Price    Amount(From Formula Volume * price)
    5                 2           10,00
    6                 3           12,00
    7                 4            28,00
    My question is how to get  a sum of (10,00 + 12,00 +28,00 = 50,00) at level 4?
    Thanks in advance.
    With regards,
    Anand

    Does anybody know how to get total at each level.
    I mean, if I have the following structure...
    Level 1
    Level 2
    Level 3
    Level 4
    Level 5
    At level 5 we have the following calculation
    Volume       Price       Amount(From Formula Volume * price)
    5                     2                 10,00
    6                     3                 12,00
    7                     4                  28,00
    I am getting following results : It is adding volume and price then multiplying volume * price and giving results.
    18                  9                18 * 9 = 162,00
    But I have to get sum of  ( 10,00 + 12,00 +28,00 = 50,00) at level 4.
    My question is how to get a sum of (10,00 + 12,00 +28,00 = 50,00) at level 4?
    Thanks.
    With regards,
    Anand

  • Need quick help, please!!! How do I scan the counter and analog channel in parallel, synchronized?

    Hi,
    I'm using LabView6.1 and a PCI6014 DAQ card.
    I have to scan simultaneously an analog channel and the counter on the card. My project requires me to measure in parallel a force (a voltage on an analog channel) in correspondence to a distance (measured with a counter) and I have to display a force-distance graph.
    So, can someone please tell me how can I program the counter and an analog channel to take 1000 measurements in parallel, and then, by reading the buffers to have two sets of corresponding measurements?
    I've tried some things and I've got only an error message, that says that there is no free DMA channel available (the error comes from configuring
    the analog channel). I attached one of these programs that gives this error, maybe somebody can tell me what I do wrong.
    If somebody could send me an example (in LabView6, I have no 7 :-( ), I would be grateful.
    Thank you,
    pixooxiq
    Attachments:
    Scan_Test_4.vi ‏177 KB

    Hi pixooxiq,
    unfortunately, your Card has only one DMA-Channel.
    If you want to use two Channels simutaneously, you have to tell one of them to use an Interrupt instead.
    This option can be set with the "Set DAQ Device Information.VI"
    Just see the Bitmap, I've attached.
    Perhaps, you now get Performance-problems, cause the IRQ does not directly write the Data but involves the CPU. In this case the only possibillity is to use an other card with more than 1 DMA-Channel...
    Regards
    Peter Weber
    NI Germany
    Attachments:
    Interrupt2.bmp ‏159 KB

  • How to get succesfullt loaded count in forall

    hi,
    plz tell me how to get succefuly loaded count into a table if i m using bulk collect & forall .

    Check out the documentation:
    Counting Rows Affected by FORALL with the %BULK_ROWCOUNT Attribute
    The cursor attributes SQL%FOUND, SQL%ISOPEN, SQL%NOTFOUND, and SQL%ROWCOUNT, return useful information about the most recently executed DML statement. For additional description of cursor attributes, see "Implicit Cursors".The SQL cursor has one composite attribute, %BULK_ROWCOUNT, for use with the FORALL statement. This attribute works like an associative array: SQL%BULK_ROWCOUNT(i) stores the number of rows processed by the ith execution of an INSERT, UPDATE or DELETE statement.

  • How to get total available RAM

    Hi
    How to get total available RAM of the system. I used Runtime.getInstance().totalMemory(), it is not giving total memory of the system. I appreciate any help on this pl.
    Thx
    PK

    If there would be any operating system command
    displaying the desired result,
    we could execute it as runtime command and parse the
    output.
    But I don't know if such a command exists.
    I tried "mem", but it does not show the value I
    expected.For windows XP the following command (either in the cmd window or executed by Runtime.exec) will provide the physical memory size.
    systeminfo | find "Total Physical Memory"I don't know if it works in other Windows versions.

Maybe you are looking for

  • Performance Problem in JSF

    HI folks, My application is written using ADF Faces. This is a oracle framwork which intern uses JSF only. I wrote a small app with just single page and trying to see how well the application will scale. From my observations I found that application

  • The load process runs in the SAP GUI and the GUI will timeout if someone do

    Hi Our main issue: for loading DRW/BKT/Characteristics/Doc Files, I have already tested processing the Idocs in Background mode. All the Idocs failed because the background process on the SAP application server cannot access the doc files. (it has to

  • Installing Elements over the Free Trial

    Below is a message I get when trying to install a FULL copy of Elements 6 purchased from the apple store on a mac that has the trial version of Elements 6 installed. Whether I try to install the store copy with the trial version still on the hard dri

  • Get a VBA error when I run queries

    I am running into an error when I try to run any queries.  the error says Object Library feature not supported and goes into the VBA code.  any ideas how to fix this error?

  • Cannot upload to .Mac homepage!

    I'm having the same problems many others are having. iPhoto 5.0.1 works fine in all aspects except for uplaoding to my .Mac webpage. I get the long drawn out "updating themes followed by a "connection cannot be established at this time. Please make s