Median function in SSAS is doing a sum instead

Hi, i am new to SSAS and mdx. I'm trying to get the median, however the function seems to return the sum of all record for that field/column group.
For example, this is the fact table that i have:
DEPT QUARTER
GROUP TIME
1 2012Q1
A 1
1 2012Q1
A 5
1 2012Q1
A 20
1 2012Q1
A 30
1 2012Q1
B 10
1 2012Q1
B 15
1 2012Q1
B 20
1 2012Q1
B 31
1 2012Q2
A 8
1 2012Q2
A 10
The result should be:
Median
DEPT QUARTER
GROUP MEDIANTIME
1 2012Q1
A 12.5
1 2012Q1
B 17.5
1 2012Q2
A 9
instead it's showing :
DEPT QUARTER
GROUP MEDIANTIME
All All
A 150
All All
B 150
All 2012Q1
A 132
All 2012Q1
B 132
All 2012Q2
A 18
etc.
The mdx is :
With MEMBER  [Measures].[Median] AS Median([DIM GROUP].[GROUP].Members,
        [Measures].[TIME])
SELECT  {[Measures].[Median]} ON 0,
        NonEmpty([DIM DEPT].[DEPT].MEMBERS)*NonEmpty([Dim DATE].[Quarter].MEMBERS)*NonEmpty([DIM GROUP].[GROUP].Members) ON 1
FROM    [TIME CUBE]
Can someone please advise how to fix this? to get the median value instead of the sum of each group?
2 more questions that arose:
1. When i searched on the mdx syntax, some people recommend to have the [GROUP].[GROUP] repeated twice, can someone please explain the difference between [DIM GROUP].[GROUP].[GROUP].Members AND [DIM GROUP].[GROUP].Members?
2. Why do the "all" show up in the result, can we exclude it?
Thanks a lot in advance.
--Elys

Hi Elys ,
You should use the 'EXISTING' functionality .
With MEMBER [Measures].[Median] AS Median(EXISTING([DIM GROUP].[GROUP].Members),
[Measures].[TIME])
SELECT {[Measures].[Median]} ON 0,
NonEmpty([DIM DEPT].[DEPT].MEMBERS)*NonEmpty([Dim DATE].[Quarter].MEMBERS)*NonEmpty([DIM GROUP].[GROUP].Members) ON 1
FROM [TIME CUBE]
And for the 'All' member : If you have enabled 'AttributeHierarchyEnabled' property of GROUP to true (default), you will have an all member . Using [Dim Group].[Group].[Group] will exclude the 'All' member and will present only the actual groups .
Regards, David .

Similar Messages

  • What does AverageOfChildren aggregate function in SSAS 2005 actually do?

    Folks,
    Have any of you been playing around with SSAS 2005 to have worked out
    what the AverageOfChildren aggregate function actually does?
    I was expecting it to do the equivalent of a simple AVG() with a GROUP
    BY in SQL, but it seems to be doing something additional to that.
    No-one in the team I work in has been able to work out what exactly it
    is doing.
    Any info would be appreciated!
    Cheers,
    Kenneth

    This very question was recently discussed in the public SQL Server OLAP newsgroup:
    http://groups.google.com/group/microsoft.public.sqlserver.olap/msg/c662e201b99678bc
    >>
     Aggregate Function Average of Children does not work
    This behavior could occur because
    AverageOfChildren,FirstChild,LastChild,FirstNonEmpty and LastNonEmpty are
    semi-additive and treats the Time dimension different from the other
    dimensions. Please refer to the following link for details:
    http://msdn2.microsoft.com/en-us/library/ms175356.aspx
    The description in above link (BOL) is not very clear about
    AverageOfChildren, and I have forward this feedback to the proper channel.
    The AverageOfChildren only applys when aggregating via Time dimension.  
    Actually, when you try to create a new measure in cube, when you select
    usage, you could see "average over time" which is for AverageOfChildren.
    To get the result of average behavior you want, you may want define a Sum
    and a Count measure, then create a calculated measure (in the cube script)
    which divides the two base measures.
    >>

  • Trouble with median function

    I need to use median function in fact table in my repository. In business model I have fact table with logical column(column where I used median function with name "MyCalculacion"). And I have Time dimension with column ("Year", "Quarter"(with value: 1,2,3,4) and "Month"(with value: 1,2,3,4...12))
    In Answers if I have this query with 3 column: "Year","Quarter", "MyCalculacion" I don't get good result set...
    This is SQL query from BI in this case
    select T6532.CAL_YEAR as c2,
    T6532.CAL_QTR as c3,
    T4899.OUTCOME_ID as c5
    from
    W_DAY_D T6532,
    (select ID,outcome_id,eventtime from event where dtype='Discharge' ) T4899
    where ( T4899.EVENTTIME = T6532.CALENDAR_DATE )
    order by c3
    But when I only change function from Median to StdDev(Standard Deviation) in column "MyCalculacion" I get good result. I have this SQL query:
    select T6532.CAL_YEAR as c1,
    T6532.CAL_QTR as c2,
    stddev_samp(T4899.OUTCOME_ID) as c3
    from
    W_DAY_D T6532,
    (select ID,outcome_id,eventtime from event where dtype='Discharge' ) T4899
    where ( T4899.EVENTTIME = T6532.CALENDAR_DATE )
    group by T6532.CAL_QTR, T6532.CAL_YEAR
    order by c1, c2
    I "bolded" important difference.In this case BI create query with function stddev_samp.
    After this i trued with some other function in my logical column. And good result are always when is function in SQL query. So OK is when I used StdDev,StdDevPop,avg,count,sum , but not OK with Median,First,Last...
    any help and/or clue?
    thanks in advance

    ... so Fringe is loaded for each Product Line but not for any particular project, therefore at a 'Project_na'??<BR>if so, you could <BR>1) Create a parent for 'Projects' - outline now<BR>Contract<BR> |--Project_na<BR> |--Projects (parent)<BR> |--Project1 (child)<BR> |--Project2....(child)<BR> <BR>Then, if I understand your requirements, I think your calc script could be.....<BR><BR>FIX(Scenario, period, fiscalYear,currency,Product_na)<BR> FIX(AIR)<BR> Fringe=@ALLOCATE(Project_na,@RELATIVE(Projects,0),directLabour,,SHARE);<BR> ENDFIX<BR> FIX(NAVY)<BR> Fringe=@ALLOCATE(Project_na,@RELATIVE(Projects,0),directLabour,,SHARE);<BR> ENDFIX<BR> FIX(LAND)<BR> Fringe=@ALLOCATE(Project_na,@RELATIVE(Projects,0),directLabour,,SHARE);<BR> ENDFIX<BR><BR>This would (for each product line) allocate Fringe-> Project_na to Fringe->@relative(projects) based upon Direct Labour costs. Assuming that Accounts are Dense, this shouldn't create block creation errors since DirectLabour already exists / therefore Block exists?<BR><BR>(Am I correct here?)

  • Median function in 10gR2

    I am seeing some unexpected behavior using the median function applied to a set of distinct values returned by a subquery. I didnt find an explanation by searching the web; hence the question here. These queries are on a 10gR2 database.
    In both cases below, the select distinct should return 1,2,3,4,5; for a median of 3.
    However the median is different when the 1,2 are repeated
    This query returns 2 as median -
    SELECT median(prob)
    FROM (SELECT DISTINCT (prob) AS prob
    FROM (SELECT 1 AS prob
    FROM dual
    UNION ALL
    SELECT 2 AS prob
    FROM dual
    UNION ALL
    SELECT 3 AS prob
    FROM dual
    UNION ALL
    SELECT 4 AS prob
    FROM dual
    UNION ALL
    SELECT 5 AS prob
    FROM dual
    UNION ALL
    SELECT 1 AS prob
    FROM dual
    UNION ALL
    SELECT 2 AS prob FROM dual) sub);
    This query returns 3 as the median.
    SELECT median(prob)
    FROM (SELECT DISTINCT (prob) AS prob
    FROM (SELECT 1 AS prob
    FROM dual
    UNION ALL
    SELECT 2 AS prob
    FROM dual
    UNION ALL
    SELECT 3 AS prob
    FROM dual
    UNION ALL
    SELECT 4 AS prob
    FROM dual
    UNION ALL
    SELECT 5 AS prob FROM dual) sub);
    What am I missing about the median or the distinct function to cause this different behavior? My expectation was to get the same median - 3 - in both cases since the subquery that the median uses returns the same values in both.
    Thanks in advance for any insight on this.

    My guess would be that it is a bug, not sure if it is a known one, but I can reproduce it in 11.1.0.7.
    From the documentation:
    "The result of MEDIAN is computed by first ordering the rows. Using N as the number of rows in the group, Oracle calculates the row number (RN) of interest with the formula RN = (1 + (0.5*(N-1)). The final result of the aggregate function is computed by linear interpolation between the values from rows at row numbers CRN = CEILING(RN) and FRN = FLOOR(RN)."
    What I think is going on is that the distinct causes a hash unique to be performed, but somewhere median (or the optimizer) is assuming that the rows are already ordered because of the distinct so is not doing its own sort.
    SQL> SELECT distinct prob
      2        FROM (SELECT 1 AS prob FROM dual UNION ALL
      3              SELECT 2 FROM dual UNION ALL
      4              SELECT 3 FROM dual UNION ALL
      5              SELECT 4 FROM dual UNION ALL
      6              SELECT 5 FROM dual UNION ALL
      7              SELECT 1 FROM dual UNION ALL
      8              SELECT 2 FROM dual);
          PROB
             5
             1
             2
             3
             4So, it correctly calculates RN as 3, but the value at row 3 is 2.
    The analytic version probably forces a sort, and in the group by version, median (or the optimizer) probably recognizes that a hash algorithm would be used for the grouping.

  • Preview does not sum column data in PDF forms

    Preview is way better than Acrobat for most purposes, but it has some basic limitations that just make it hard to use. for example I have to use this form that asks you to enter $ in a table, however Preview does not sum the column, it just puts a "0" in. Why doesn't Preview add? Plus, this default behaviour makes it harder to paste in my own number as there is a zero in the way. At least it would be nice if it could just remove the 0 and leave me with an editble section. Is this just the product of a badly created PDF form or, as I suspect, a limitation of Preview?

    I'm having the exact problem. I have a fillable PDF form that has many checkboxes. Saving the pdf (doesn't matter whether it's 'Save', 'Save All', or 'Save As' under the File menu) will clear/reset the checkboxes in the file.
    Anyone know of a workaround for this? Or, is Apple fixing this soon? I really don't want to get Acrobat Pro 9 (well, I don't think it's compatible with Snow Leopard yet anyway)
    If you'd like a sample PDF file to try it out, let me know.
    Thanks.

  • The list of extensions for InDesign now have a yellow triangle warning symbol in front of a good many of the extensions and when moused over i get one of two messages:  "Extensions may not function properly because it does not meet the dependency conditio

    The list of extensions for InDesign now have a yellow triangle warning symbol in front of a good many of the extensions and when moused over i get one of two messages:
    "Extensions may not function properly because it does not meet the dependency condition."
    OR
    Extension Status is not consistent with extension set configuration."
    The reason I opened the Extension Manager in the first place was to check to see if I had installed a third party extension.  And I was presented with these warning symbols.  I haven't added anything, I haven't done anything that would cause this.
    Does anyone know how to fix this???
    I am running OSX 10.9.5; Indesign CS6 version 8.0.2 And Adobe Extension Manager version  6.0.8.28.
    Thanks in advance!
    Nina

    Many InDesign pre-installed extensions (Those extensions you have immediately after InDesign installation) define dependency rules in their mxi files. Dependency means that one extension works well only if one or more other extensions are installed and enabled. If this condition is not met, the yellow triangle warning will be shown.
    You can select an extension with warning, click "Advanced" tag page in the lower right panel. You will see "This extension has dependency on: <extension name> ...". Check whether every extensions listed here are available and enabled. If not, enable them. Repeat these steps for all the extensions which have warning.

  • My copy and paste functions are not working, does anyone know why this might be happening?, my copy and paste functions are not working, does anyone know why this might be happening?

    my copy and post functions are not working, does any one know why this may be happening and what I could do to fix it? Thanks!

    Have you tried rebooting?

  • THE DETACH FROM TEMPLATE FUNCTION IN DREAMWEAVER CC DOES NOT SEEM TO BE FUNCTIONAL Can you please explain.

    The detach from template function in Dreamweaver CC does not seem to be functional
    Can some explain.
    Bruce K.

    Hi Lalita
    Yes you are correct, I TRY THE Modify -> Templates -> Detach from Template.     I have built over 50 websites with this method using Modify -> Templates -> Detach from Template in DW CS5.5
    After a save a page to a template for future ref.
    I create a new page using this temp. but can not use the Modify -> Templates -> Detach from Template. The Detach from Template is not functional. It is there but when I mouse over its not operative.
    Does DW CC need update maybe.
    Thanks
    Bruce

  • Median function in BEx query based webi report

    Hi Experts,
              I have a requirement to have a median function in a chart in my webi report. I'm using BO 4.0 SP2 Fix pack 2.9 and using IDT connection to connect BEx queries. I have 3 dimension objects in X axis and Median as y axis. When i'm calculating median, it need to have the child dimension aslo be part of the chart. but my requirement the child dimension should not be in the chart.
    Example: i have Region, Country and state dimensions as X axis, and Median of sales revenue by city as y axis.
    In my chart, i should not include city. So i have written the formula like "Median(Sales revenue) Forall(City) in (Region;Country; state)" and i tried all the combinations of this.
    When i'm including the city object its working fine, but when removint it, its not. Please help me in this.
    Thanks.

    Hi Suman,
    thanks aigain for your reply!
    I have tried your proposal before you have posted it.
    In my special case the following if/else statement works successfully:
    CKF = calculated key figure
    Formula1 = (CKF1 == 0) * 0 + (CKF1 <> 0) * CKF2
    In my case the CKF2 is the result value from "Incoming Order value" - "Turnover"
    So I had to define a separate Formula (1:1 equals to CKF2) and then I was able to set "*CKF2" in the statement.
    The statement CKF2 = (CKF1 == 0) * 0 + CKF2 is not possible (because it´s not possible to calculate from CKF2 itself).
    Now it works
    Best regards,
    Michael

  • Pricing schema does not sum two quantities

    Dear all,
    Pricing schema does not sum two quantities
    300     0     NETW               
    301     0     OWST          210     210
    302     0     YOKI          300     301---Here I expext from SAP to sum NETW and OWST.
    However it does not do it.
    How can I fix this error.

    I read our PP as Line 302 will use the sum of lines 301 and 302 as the base for the YOKI condition.
    The pricing procedure never adds quantities - it only adds values. Not sure if that is what you are intending.
    Look at the details for the line and check if the base value is what you expect.
    Also check the following:
    1. Is there a Alt Condition Base formula on line 302?
    2. Is YOKI a condition that uses the value as a base. (If it's based on quantity, then the value is not used.)
    If you want to have line 302 as sum of the values from 300 and 302 - remove the condition type from the line.

  • Function module /SDF/AL_MAP_TRANSID_LOGH does not exist

    When I am trying to activate query 0PT_C01_Q001 (DR4U5LBSCW5LRFCNU7PU3VTZZ) of Time Management InfoCube (0PT_C01 - Time and Labor) from BI Content, the following errors are happening.
    Error when activating element B4RCXIS1HI47GC93QSNYJYZRZ
    Function module /SDF/AL_MAP_TRANSID_LOGH does not exist
    Error when activating element DR4U5LBSCW5LRFCNU7PU3VTZZ
    Function module /SDF/AL_MAP_TRANSID_LOGH does not exist
    Function module /SDF/AL_MAP_TRANSID_LOGH does not exist
    So instead of Query this time I went to activate only Structure B4RCXIS1HI47GC93QSNYJYZRZ.
    This time also it is showing the following errors
    Error when activating element B4RCXIS1HI47GC93QSNYJYZRZ
    Function module /SDF/AL_MAP_TRANSID_LOGH does not exist
    Regarding function module /SDF/AL_MAP_TRANSID_LOGH error, I implemented Note 1114719 - Error when activating Content (/SDF/AL_MAP_TRANSID_LOGH)
    We are using Support Package SAPKW70016 - SAP NetWeaver BI 7.0
    Even after implementing Note 1114719, this error is still happening.
    Any help on this issue would be great.
    Thanks in advance
    Subra

    After implementing the notes, when I installed it in the background, it worked. In the front end it is still not working.

  • I have acrobat pro on my lap top and recently installed acrobat pro on my Mac Mini, but the text recognition function is not working, does anyone have any advice on how to remedy this problem?

    I have acrobat pro on my lap top and recently installed acrobat pro on my Mac Mini, but the text recognition function is not working, does anyone have any advice on how to remedy this problem?

    On my laptop when I open up a pdf file and do a search for a particular
    text phrase it prompts me to run a character analysis.  Whereas on my mac
    mini, when I try to engage the same process it just says it couldn't find
    the phrase and doesn't even try and run a character analysis. I tried
    clicking on the tool bar and the recognize text tab but nothing there seems
    to do anything.
    In trying to figure out the issue on my own I noticed one thing.  I run a
    small law firm in St. Louis and I scan in all my files to which are
    subsequently emailed to my outlook account where I will save them as pdf's
    to their respective folders.  On my laptop when I open up an email from my
    scanner I see the image of a acrobat document next to the attachment
    paperclip symbol.  However, when I open up the same email on my mac mini I
    notice instead of an acrobat file image it shows a Preview file image (the
    program used to open up pdf's before I installed acrobat).
    Hope this helps!
    Sincerely,
    Jonathan McAllister

  • When I open a new website, the page does not open, instead it places a tab in the bottom task bar? How can I change the settings so as when I open a new website the page is automatically displayed on my desktop. Thank You!

    When I open a new website, the page does not open, instead it places a tab in the bottom task bar? How can I change the settings so as when I open a new website the page is automatically displayed on my desktop. Thank You!

    Tools > Options > Tabs - is the last preference there check-marked??

  • Drag and Drop (Trying to do a copy but it does a Move instead)?

    I have implemented drag and drop throughout my application and it works fine as long as I drag from a non-editable component (Table, TextArea, etc.) to an editable component (TextArea or TextField). However, When I drag and drop from an editable component to another editable component it does a move instead. How do I force it to do a copy? I looked at the description of exportAsDrag(JComponent comp, InputEvent e, int action) method and it even says for the action that no matter what you put in there "...the value may be changed during the course of the drag operation". What exactly causes this possible change and how do I prevent it from happening?
    This is the constructor I currently have:
    public TextAreaPanel(Document doc)
      super(doc);
      setMargin(new Insets(12,12,12,12));
      setDragEnabled(true);
      addMouseListener(new MouseAdapter()
        @Override public void mousePressed(MouseEvent e)
          if(e.getButton() != MouseEvent.BUTTON1)
            TextAreaPanel area = (TextAreaPanel)e.getSource();
            area.getTransferHandler().exportAsDrag(area, e, TransferHandler.COPY);
    }I forgot to mention before. The location of the component having the text copied into it is in a different JInternalFrame than the one where the text is being copied from (not sure if that matters or not).
    Edited by: Dont_Know on Jan 18, 2008 6:25 AM
    Edited by: Dont_Know on Jan 18, 2008 6:28 AM

    If your problem persists get yourself a micro USB cable (sold separately), you can restore your Apple TV from iTunes:
    Remove ALL cables from Apple TV. (if you don't you will not see Apple TV in the iTunes Source list)
    Connect the micro USB cable to the Apple TV and to your computer.
    Open iTunes.
    Select your Apple TV in the Source list, and then click Restore.

  • ICloud symbol in settings does not appear, instead there is the one for MobileMe, what do I have to do or didn't do well?

    iCloud symbol in settings does not appear, instead there is the one for MobileMe, what do I have to do or didn't do well?
    Thanks in advance

    If your Mac is one year old it did not come with Lion, so you must have purchased and installed it yourself, or it is not installed.
    Do this
    Go to Apple Menu>About This Mac:
    It should look like this:
    If your version is anything other than 10.7.xx you do not have Lion (10.6 is Snow Leopard)

Maybe you are looking for

  • COMPUTE_BCD_OVERFLOW on MIRO. Any SAP NOTE?

    Hi, I'm getting a COMPUTE_BCD_OVERFLOW dump with the  the CX_SY_ARITHMETIC_OVERFLOW exception when doing a MIRO process. The user is using huge values in the PO and the error is related to a multiplication between this values. (EKTE table is hoding t

  • PP02 item category change

    Hi, when the system creates any PR against PP02 control key in order operation, it will have L item category, is it possible to change that to D type ?

  • HTTPS/Bluetooth/Proximity

    Instead of the ultrasonic token having the proximity app use htttps could we have it use Bluetooth? That way users that are non-employees (can not get on the network) that are part of the meeting can connect the app to the TP endpoint?

  • New iMac keeps freezing / crashing

    My new iMac, which was absolutely fine for several months after I bought it last Autumn, is getting to the point of being almost unusable. It freezes / crashes (annoying spinning beachball) doing the most simple of tasks (e.g saving files, in Entoura

  • Why should we upgrade to OBPM 11g?

    Hi all, I am currently using OBPM 10g. Since OBPM 11g is the latest version, I would like to upgrade to 11g but from end user perspective what are the advantages of using OBPM 11g. These are the questions I have regarding OBPM 11g. Can you help me wi