Bug in excel 2012/pivot/summation of calculated field

I have a calculated field (called TO) in a pivot
= if(time >= 600,1,0)
where time is a field.
I present it in 'values' with 'sum'. It shows correct values, but the sub-totals are wrong. I can send an example if you tell me where to...

It's not a bug, it's a consequence of the way calculated fields work. You should read your formula as
=IF([subtotal of time in pivot table]>=600,1,0)
To calculate what you want, add a column with formulas to the source data of the pivot table.
Regards, Hans Vogelaar (http://www.eileenslounge.com)

Similar Messages

  • DAX Dynamic Banding | Calculated Member based on Calculated Field

    Good morning,
    I've created a Power Pivot model that measures the blood glucose levels of clinical patients at specific times of the day. The requirement is that this metric, let's call it GlucoseLevel, is always averaged as it wouldn't make sense to sum up the values.
    To meet this first requirement, I set the "Summarize By" property of the GlucoseLevel column to "Average".
    The second requirement is to band the GlucoseLevel values so that groups of people can be measured by this band rather than by the individual measure values. I created a banding table in Excel and then imported it into the Power Pivot model. The banding table
    has three columns (BandName, MinValue and MaxValue) and has the following values:
    VERYLOW: Min Value = 0; Max Value = 3.99
    OK: Min Value = 4; Max Value = 6.99
    WARNING: Min Value = 7; Max Value = 10.99CRITICAL: Min Value = 11; Max Value = 30.00
    It is at this point where I face my challenge. I have a GlucoseLevel measure and I have a banding table. Great. The challenge is: How do I create a calculated, dynamic
    member that will look at my GlucoseLevel measure (at whatever level), do a lookup to my banding table, and then return the "BandName" column from the Banding table at that specific level? So to clarify what I mean by level: I want to be able
    to view the bandings at Year level, or a Month level, or even at a week level. Then depending on what level I am at, my measure should have a Band associated to it.
    I've tried to solve this issue in a couple of ways:
    Attempt 1
    Create a calculated column in my fact table that contains a nested IF statement to manually band my GlucoseLevel values. This works fine if I view my data at the lowest level of granularity, however
    it does not work if I start looking at my data at the day, week, month etc. levels
    Attempt 2
    1.) Create a calculated field (not a calculated column) that averages my GlucoseLevel measure. This is cool because it will average my measure at whatever level I am viewing it at. Let's call
    this field Bob...
    2.) Band my measure Bob by creating another calculated field (called PatientBand). This field uses my banding table (described earlier) in conjunction with my calculated field Bob. This works perfectly, except for one big flaw: Excel sees this banding field
    as a measure, and not as something that I can use as a column / row...
    So my question is: Can I trick Excel into viewing my PatientBand calculated field as an attribute, and not as a measure? And if not, how do I get around this challenge? Here is the DAX formula that I used to create my second calculated field "PatientBand":
    PatientBand:=CALCULATE(
        VALUES (Bandings[BandName]);
        FILTER (
            Bandings; 
            Test[Bob] >= Bandings[MinValue]
         && Test[Bob] <= Bandings[MaxValue]
    Thanks!

    So there are 2 ways that I can think of for doing that.
    1) if you are only using MDX clients like Excel or Reporting services you can create a text based measure that returns the banding name. (Note that this sort of approach does not work at the moment with PowerView as it only displays numeric measures). This
    would effectively let you show a label next to a reading as opposed to moving the reading under a given banding column.
    Banding Name :=
    CALCULATE (
        VALUES ( Bands[BandName] ),
        FILTER (
            Bands,
            [Average of GlucoseReading] >= Bands[BandMin]
                && [Average of GlucoseReading] <= Bands[BandMax]
                && NOT ( ISBLANK ( [Average of GlucoseReading] ) )
    2) This next approach will show the results exactly as you had them in your sample screenshots. It just takes a slight bending of the DAX. I'm using a SUMX here, not because I want to sum anything, but because the "X" version of SUMX basically loops over
    every row in the specified table and sums the expression in the second parameter. I have setup the second parameter so that it only returns a single value for the average if it is in the appropriate banding. 
    Banded Average:=IF (
        HASONEVALUE ( Bands[BandName] ),
        SUMX(
            'Bands',
            IF (
                NOT ( ISBLANK ( [Average of GlucoseReading] ) )
                    && [Average of GlucoseReading] >= MIN ( Bands[BandMin] )
                    && [Average of GlucoseReading] <= MIN ( Bands[BandMax] ),
                AVERAGE(Readings[GlucoseReading]),
                BLANK()
    ,AVERAGE(Readings[GlucoseReading])
    http://darren.gosbell.com - please mark correct answers

  • IF statement in Calculated Field for Share point, doesnt calculate sum in my Excel Pivot table.

    Hi Everyone
    I used this in SP calculated column field.
    =IF([Shift Sched]="1pm to 10pm","0",IF([Shift Sched]="2pm to 11pm","1",IF([Shift Sched]="3pm to 12am","2",IF([Shift Sched]="4pm to 1am","3",IF([Shift Sched]="5pm to 2am","4",IF([Shift
    Sched]="6pm to 3am","5",IF([Shift Sched]="7pm to 4am","6",IF([Shift Sched]="8pm to 5am","7",IF([Shift Sched]="9pm to 6am","8",IF([Shift Sched]="10pm to 7am","8",IF([Shift
    Sched]="11pm to 8am","7",IF([Shift Sched]="12pm to 9am","6",IF([Shift Sched]="1am to 10am","5",IF([Shift Sched]="2am to 11am","4",IF([Shift Sched]="3am to 12pm","3",IF([Shift
    Sched]="4am to 1pm","2",IF([Shift Sched]="5am to 2pm","1",IF([Shift Sched]="6am to 3pm","0",IF([Shift Sched]="7am to 4pm","0",IF([Shift Sched]="8am to 5pm","0",IF([Shift
    Sched]="9am to 6pm","0",IF([Shift Sched]="10am to 7pm","0",IF([Shift Sched]="11am to 8pm","0",IF([Shift Sched]="12pm to 9pm","0"))))))))))))))))))))))))    
    it was able to work fine however my issue is when i extract the information to excel and use a pivot table the table is not able to calulate the sum of the value for this field. Can you please help me with this. this is for an Attendance traker for Night
    Differential pay for employees. they create a daily log of their shift schedule and if i summarize this in pivot the value in the calculated field for this is not getting the sum.
    Thanks,
    Norman

    Hi Everyone
    I used this in SP calculated column field.
    =IF([Shift Sched]="1pm to 10pm","0",IF([Shift Sched]="2pm to 11pm","1",IF([Shift Sched]="3pm to 12am","2",IF([Shift Sched]="4pm to 1am","3",IF([Shift Sched]="5pm to 2am","4",IF([Shift
    Sched]="6pm to 3am","5",IF([Shift Sched]="7pm to 4am","6",IF([Shift Sched]="8pm to 5am","7",IF([Shift Sched]="9pm to 6am","8",IF([Shift Sched]="10pm to 7am","8",IF([Shift
    Sched]="11pm to 8am","7",IF([Shift Sched]="12pm to 9am","6",IF([Shift Sched]="1am to 10am","5",IF([Shift Sched]="2am to 11am","4",IF([Shift Sched]="3am to 12pm","3",IF([Shift
    Sched]="4am to 1pm","2",IF([Shift Sched]="5am to 2pm","1",IF([Shift Sched]="6am to 3pm","0",IF([Shift Sched]="7am to 4pm","0",IF([Shift Sched]="8am to 5pm","0",IF([Shift
    Sched]="9am to 6pm","0",IF([Shift Sched]="10am to 7pm","0",IF([Shift Sched]="11am to 8pm","0",IF([Shift Sched]="12pm to 9pm","0"))))))))))))))))))))))))    
    it was able to work fine however my issue is when i extract the information to excel and use a pivot table the table is not able to calulate the sum of the value for this field. Can you please help me with this. this is for an Attendance traker for Night
    Differential pay for employees. they create a daily log of their shift schedule and if i summarize this in pivot the value in the calculated field for this is not getting the sum.
    Thanks,
    Norman

  • Excel 2012 SP1 plagin for Master Data Services - Bugs ???

    Excel 2012 SP1 plagin for Master Data Services 32bit or 64bit
    1.  
    My entity A has 50,000 records.
    Entity B has a domain attribute "City" from entity A.
    I successfully add new records to the entity B, but after refresh I cannot see any data in the domain attribute "City" for new records (empty cels)!!! Although in the Web client (or through SSMS in table)  I can see the data in "City"
    attribute (e.g. code_095 {Moscow}).
    If I reduce the number of records in the entity A to 20 000, then I see code_095 {Moscow} in Excel 2012 SP1 plagin for MDS.
    Bug???
    2.
    Why Excel 2012 SP1 plagin for MDS resets the format cells ???  Bug???
    3.
    I have created rows for my own headings (business captions) above the MDS-table in the Excel-worksheet.
    Excel 2012 SP1 plagin for MDS: Why after applying the filter (query from server) Excel-worksheet completely recreated ?
    And all my row headers have been removed!!! What the hell ?
    from Moscow with money

    Superbluesman, is this still an issue? This looks like a bug. Did you file a Connect Item?
       Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Complex Calculations in Excel 2010 Pivot Tables

    Douglas R. Eckert

    It would be better if you can provide us with more information for this issue....
    In PivotTable reports, you can use summary functions or customer calculations in value field. You can also create your own formulas in calculated fields and calculated items.
    Please refer to:http://office.microsoft.com/en-gb/excel-help/calculate-values-in-a-pivottable-report-HP010382405.aspx?CTT=5&origin=HP005200663

  • Powerview vs excel Power Pivot Services vs Performancepoint Server vs SSRS

    Hi Guys,
    Need difference for below:
    Powerview vs. Excel Power Pivot Services vs. PerformancePoint Server vs. SSRS
    Can you provide clarity on when to use which tool?
    How is authentication/authorization of reports taken care in each?
    Why so many different tools?
    Regards,
    Navin
    Navin.D http://dnavin.wordpress.com

    Hi ,
    Power View :
    Power View provides intuitive ad-hoc reporting for business users such as data analysts, business decision makers, and information workers. They can easily create and interact with views of data from data models based on PowerPivot workbooks or tabular models
    deployed to SQL Server 2012 Analysis Services (SSAS) instances. Power View is a browser-based Silverlight application launched from SharePoint Server 2010.detials
    Power Pivot : is a free add-in to the 2010 version of the spreadsheet application Microsoft Excel. In Excel 2013, Power Pivot is only available for certain versions of Office.[1] It extends the capabilities of the pivot table data summarization
    and cross-tabulation feature with new features such as expanded data capacity, advanced calculations, ability to import data from multiple sources, and the ability to publish the workbooks as interactive web applications.[2] As such, Power Pivot falls under
    Microsoft's Business Intelligence offering, complementing it with its self-service, in-memory capabilities.details
    understanding-powerpivot-and-power-view-microsoft-excel-2013
    PerformancePoint Services lets you create rich dashboards, aggregating content from multiple sources and displaying it in a web browser in an understandable and collaborative environment. The rich interactivity of the dashboards lets you
    to analyze the latest information and work with the data quickly and easily to identify key opportunities and trends. PerformancePoint Services and its authoring tool Dashboard Designer let you display key performance indicators (KPIs) and data visualizations
    in the form of scorecards, analytic reports, and filters. You can integrate with SQL Server Reporting Services (SSRS)and Excel Services in addition to create scorecards that bring together data from multiple data sources to track and monitor key drivers of
    your business.
    http://www.codeproject.com/Articles/783405/PerformancePoint-Services-in-SharePoint
    “SQL Server Reporting Services 2008 (SSRS)”. SSRS is a full-featured application that provides report design, development, testing, and deployment of reports by the use of Business Intelligence Development Studio (BIDS) developer tool for all
    its operations.
    http://www.codeproject.com/Articles/621332/Building-Your-First-SSRS-Report
    thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com

  • Running total of calculated field in pivot

    VERSION: ORACLE 11
    TABLE:
    create table chart_detail (
    DIS        NUMBER,
    BLD_MO VARCHAR2(7),
    BLD        NUMBER(10),
    RPLC      NUMBER(10));DATA:
    insert into chart_detail values (60,'2011-03',0,2);
    insert into chart_detail values (150,'2011-04',10572,0);
    insert into chart_detail values (120,'2011-04',26449,5);
    insert into chart_detail values (30,'2011-04',0,1);
    insert into chart_detail values (60,'2011-04',0,7);
    insert into chart_detail values (90,'2011-04',0,9);
    insert into chart_detail values (120,'2011-05',5714,0);
    insert into chart_detail values (90,'2011-05',24557,1);
    insert into chart_detail values (60,'2011-05',0,4);
    insert into chart_detail values (30,'2011-05',0,0);
    COMMIT;EXPECTED RESULTS:
         2011-04                    2011-05               
    DIS     RPLC     BLD     TBLD     IPTV     RPLC     BLD     TBLD     IPTV
    30     1     0     37021     0.03     0     0     30271     0.00
    60     7     0     37021     0.22     4     0     30271     0.13
    90     9     0     37021     0.46     1     24557     30271     0.17
    120     5     26449     37021     0.59     0     5714     5714     0.17
    150     0     10572     10572     0.59               0     
    180               0                    0     
    TOTAL     22     37021               5     30271          PROBLEM: I need to have a running total of IPTV like in the above example. I can get the IPTV for each DIS/bld_mo but I don't know how to get the running total of it. In the script below I just used an example where I tried summing the IPTV like was done for build. I know it can't be done that way because IPTV is a calculated field in the query but if I substitute "APR_IPTV" with the formula for IPTV I get an error that window functions aren't allowed here. I do not know a way around this. I commented out the bad piece of code.
    PROBLEM SCRIPT:
    WITH  pivot_results  AS
      SELECT    dis
      ,    NVL (apr11_rep,  0)  AS apr11_rep
      ,    NVL (apr11_bld,   0)  AS apr11_bld
      ,    NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tbld
    ,      DECODE(NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(apr11_rep, 0)*1000/ NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS apr11_iptv               
    ,      NVL ( SUM (apr11_iptv)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tiptv  
      ,    NVL (may11_rep,  0)  AS may11_rep
      ,    NVL (may11_bld,   0)  AS may11_bld
      ,    NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS may11_tbld
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptv
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_tiptv               
      FROM     chart_detail
      PIVOT     (  MAX (rplc)  AS rep
              ,  MAX (bld)  AS bld
              FOR  bld_mo   IN ( '2011-04'  AS apr11
                                             , '2011-05'  AS may11
    SELECT    CASE
            WHEN  GROUPING (dis) = 0
            THEN  TO_CHAR (dis)
            ELSE  'Total'
        END      AS dis
    ,    SUM (apr11_rep)  AS apr11_rep
    ,    SUM (apr11_bld)  AS apr11_bld
    ,    SUM (apr11_tbld) AS apr11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_iptv)
        END      AS apr11_iptv
    ,    SUM (apr11_tiptv) AS apr11_tiptv
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_tpiptv)
        END      AS apr11_tiptv
    ,    SUM (may11_rep)  AS may11_rep
    ,    SUM (may11_bld)  AS may11_bld
    ,    SUM (may11_tbld) AS may11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (may11_iptv)
        END      AS may11_iptv   
    FROM    pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Thank you,

    Hi,
    So you know how to compute iptv for an individual row; the problem now is that you want to get a running total of iptv; is that it?
    The problem there is that computing iptv requires an analytic function, and analytic functions can't be nested. To get the results of nesting f (g (x)), where f and g are analytic funtions, you have to compute g in a sub-query, and then use the results as the argument to f in a super-query.
    Here's how to apply that to your situation:
    WITH  pivot_results  AS
         SELECT    dis
    -- April, 2011
           ,           NVL (apr11_rep,   0)  AS apr11_rep
           ,           NVL (apr11_bld,   0)  AS apr11_bld
           ,           NVL ( SUM (apr11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS apr11_tbld
         ,      NVL ( 1000 * apr11_rep
                              / NULLIF ( SUM (apr11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS apr11_iptv
    -- May, 2011
           ,           NVL (may11_rep,   0)  AS may11_rep
           ,           NVL (may11_bld,   0)  AS may11_bld
           ,           NVL ( SUM (may11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS may11_tbld
         ,      NVL ( 1000 * may11_rep
                              / NULLIF ( SUM (may11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS may11_iptv
           FROM     chart_detail
           PIVOT    (    MAX (rplc)  AS rep
                    ,    MAX (bld)   AS bld
                    FOR  bld_mo   IN ( '2011-04'  AS apr11
                                      , '2011-05'  AS may11
    SELECT    CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  TO_CHAR (dis)
                  ELSE  'Total'
               END      AS dis
    -- April 2011
    ,           SUM (apr11_rep)  AS apr11_rep
    ,           SUM (apr11_bld)  AS apr11_bld
    ,           SUM (apr11_tbld) AS apr11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (apr11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS apr11_iptv
    -- May 2011
    ,           SUM (may11_rep)  AS may11_rep
    ,           SUM (may11_bld)  AS may11_bld
    ,           SUM (may11_tbld) AS may11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (may11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS may11_iptv
    FROM      pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Output:
          APR11  APR11   APR11  APR11 MAY11  MAY11   MAY11  MAY11
    DIS    _REP   _BLD   _TBLD  _IPTV  _REP   _BLD   _TBLD  _IPTV
    30        1      0   37021    .03     0      0   30271    .00
    60        7      0   37021    .22     4      0   30271    .13
    90        9      0   37021    .46     1  24557   30271    .17
    120       5  26449   37021    .59     0   5714    5714    .17
    150       0  10572   10572    .59     0      0       0    .17
    Total    22  37021  158656            5  30271   96527As you can see, this is not quite what you wanted on the row where dis='150'. You asked for NULLS in the may11_rep, may11_bld and may11_iptv columns. You can get those results if you need them; just explain the rules that govern whether to display the values and when to display NULL.
    The way you posted the sample data and results, and the quantity of sample data were all excellent; it really helped me find a solution. Thanks.
    It would have also helped it you had explained how iptv is computed. Basically, iptv = 1000 * rep / tbld, right?
    It looks like most of this code:
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptvwas a way of avoiding divide by 0 errors; it would have been helpful if you had explained that.

  • Bug in Excel's handling of metadata? Or at least a deviation from the Open Office XML specification?

    I've discovered some very strange behaviour in Excel which seems to be contrary to that documented in the Open Office XML specification (OOXML). I couldn't find a way to report bugs against Excel, so I thought I'd try to explain the issue here.
    In short it seems that Excel is removing, and incorrectly re-indexing the metadata I programatically associate with cells.
    First, a summary of the relevant parts of the specification:
    From OOXML 18.9: There are two types of metadata: "cell metadata" and "value metadata".
    Cell metadata follows the cell as it moves. Value metadata follows the value through formulae etc.
    From OOXML 18.3.1.4: The c (cell) element has cm and vm attributes which are both documented as "The zero-based index of the [cell|value] metadata...in the Metadata Part"
    From OOXML 18.9.17: The valueMetadata is "a collection of block element that each define the value metadata for a particular cell". "Cells in the workbook index into this collection".
    The valueMetadata contains bk elements which in turn contain rc (metadata record) elements
    From OOXML 18.9.15: rc elements have t (type index) and v (value index) attributes. t is a 1-based index into metadataTypes and v is a 0-based index into the futureMetadata element which matches the name of the metadata type.
    Here's an example of what this might look like:
    <c vm="0"> <!-- vm points to the first bk inside valueMetadata below -->
    <x:valueMetadata>
    <x:bk>
    <x:rc t="1" v="0" /> <!-- t points to the first metadataType below. v points to the first bk in the futureMetadata below (whose name matches the metadataType to which t points) -->
    </x:bk>
    </x:valueMetadata>
    <x:metadataTypes>
    <x:metadataType name="MyMetaType" ... /> <!-- name dictates which futureMetadata valueMetadata's v attribute indexes into -->
    </x:metadataTypes>
    <x:futureMetadata name="MyMetaType" ...>
    <x:bk>
    <x:extLst>
    <x:ext xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main" uri="http://example.com/extension" p5:value="test value" xmlns:p5="http://example.com/extension" />
    </x:extLst>
    </x:bk>
    </x:futureMetadata>
    The Problem
    From what I can tell, for values of n > 2, if you associate n cells with metadata, Excel will drop the last piece of metadata, and the one at index 1, and it will do so silently. The indices are then 0..n-3, and the association for all but the first (0
    index) will be wrong. This renders the future metadata totally useless.
    For n == 1, Excel just removes the last piece of metadata (index 1). If we try 1-based indexes for the vm attribute on the c element, we get different behaviour. This may not be relevant as it is contrary to the specification, but the slightly better behaviour
    might indicate an off-by-one error:
    n
    Deleted Indices (0-based) when using 0-based indices
    Deleted Indices (0-based) when using 1-based indices
    1
    0
    None
    2
    1
    1
    3
    1,2
    1
    4
    1,3
    1
    5
    1,4
    1
    6
    1,5
    1
    Demonstrating the Problem
    I have some example code[1] that demonstrates the problem. You will need a file called test.xlsx with cells A1..C2 populated.
    Compile the source as AddMetadata.exe then run with the test file as the only parameter:
    > AddMetadata.exe test.xlsx
    You can look at test.xlsx in Excel, Visual Studio (with the Open XML Package Editor Power Tool for Visual Studio 2010) or the Open XML SDK 2.0 Productivity Tool for Microsoft Office. Looking at the file before and after running AddMetadata.exe you should
    be able to reproduce the behaviour documented above.
    Summary
    It would be good to know if this is really an Excel bug or whether we're doing something wrong / unsupported. Any insight would be very much appreciated.
    [1] The Example code:
    namespace AddMetadata
    using System;
    using System.Linq;
    using DocumentFormat.OpenXml;
    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Spreadsheet;
    public class Program
    // The cells to associate with metadata
    private readonly static CellSpec[] CellSpecs = new[]
    new CellSpec{ Sheet = "Sheet1", Column = "A", Row = 1 },
    new CellSpec{ Sheet = "Sheet1", Column = "B", Row = 1 },
    new CellSpec{ Sheet = "Sheet1", Column = "C", Row = 1 },
    new CellSpec{ Sheet = "Sheet1", Column = "A", Row = 2 },
    new CellSpec{ Sheet = "Sheet1", Column = "B", Row = 2 },
    new CellSpec{ Sheet = "Sheet1", Column = "C", Row = 2 },
    private static readonly uint NumCells = (uint)CellSpecs.Length;
    private const string SPREADSHEET_ML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
    private const string METADATA_TYPE_NAME = "MyMetaType";
    private const string EXTENSION_URI = "http://example.com/extension";
    public static void Main(string[] args)
    if (args.Length != 1)
    Console.Out.WriteLine("AddMetadata <doc.xslx>");
    Console.Out.WriteLine(" Adds metadata to the specified document to demonstate some strange Excel behaviour");
    Environment.Exit(1);
    try
    var doc = SpreadsheetDocument.Open(args[0], true);
    StripMetadata(doc);
    AddMetadata(doc);
    AddMetadataType(doc);
    AddFutureMetadata(doc);
    AddMetadataRecords(doc);
    AssociateCellsWithMetadata(doc);
    doc.WorkbookPart.Workbook.Save();
    doc.Close();
    catch(Exception e)
    Console.Out.WriteLine(e);
    /// <summary>
    /// Strip any existing metadata.
    /// </summary>
    /// <param name="doc">The document</param>
    private static void StripMetadata(SpreadsheetDocument doc)
    var wbPart = doc.WorkbookPart;
    var cellMetadataPart = wbPart.GetPartsOfType<CellMetadataPart>().FirstOrDefault();
    wbPart.DeletePart(cellMetadataPart);
    /// <summary>
    /// Add basic metadata part structure.
    /// </summary>
    /// <param name="doc">The document</param>
    private static void AddMetadata(SpreadsheetDocument doc)
    doc.WorkbookPart.AddNewPart<CellMetadataPart>();
    doc.WorkbookPart.CellMetadataPart.Metadata = new Metadata { MetadataTypes = new MetadataTypes() };
    /// <summary>
    /// Add the metadata type used by all the metadata we're adding
    /// </summary>
    /// <param name="doc"></param>
    private static void AddMetadataType(SpreadsheetDocument doc)
    var metadata = doc.WorkbookPart.CellMetadataPart.Metadata;
    var metadataType = new MetadataType
    Name = METADATA_TYPE_NAME,
    Assign = false,
    CellMeta = false,
    ClearContents = false,
    ClearAll = false,
    ClearComments = true,
    ClearFormats = true,
    Coerce = false,
    Copy = true,
    Delete = false,
    Edit = true,
    Merge = true,
    MinSupportedVersion = 0U,
    PasteAll = true,
    PasteBorders = false,
    PasteColWidths = false,
    PasteComments = false,
    PasteDataValidation = false,
    PasteFormats = false,
    PasteFormulas = false,
    PasteNumberFormats = false,
    PasteValues = true,
    RowColumnShift = true,
    SplitAll = false,
    SplitFirst = false
    metadata.MetadataTypes.AppendChild(metadataType);
    /// <summary>
    /// Add future metadata blocks which contain the actual metadata for each cell.
    /// They are referenced by the metadata records.
    /// </summary>
    /// <param name="doc">The document</param>
    private static void AddFutureMetadata(SpreadsheetDocument doc)
    var metadata = doc.WorkbookPart.CellMetadataPart.Metadata;
    var futureMetadata = metadata.AppendChild(new FutureMetadata());
    futureMetadata.Name = METADATA_TYPE_NAME;
    futureMetadata.Count = NumCells;
    // Future metadata area
    for (var i = 0; i < NumCells; i++)
    // The metadata for each cell will be single FutureMetadataBlock containing an extension list with a single extension.
    FutureMetadataBlock futureMetadataBlock = futureMetadata.AppendChild(new FutureMetadataBlock());
    ExtensionList extLst = futureMetadataBlock.AppendChild(new ExtensionList());
    Extension ext = extLst.AppendChild(new Extension());
    ext.Uri = EXTENSION_URI;
    ext.AddNamespaceDeclaration("x", SPREADSHEET_ML_NS);
    ext.SetAttribute(new OpenXmlAttribute("value", ext.Uri, string.Format("test value {0}", i)));
    /// <summary>
    /// Add metadata records which point to each future metadata block.
    /// They are in turn referenced by the cells.
    /// </summary>
    /// <param name="doc">The document</param>
    private static void AddMetadataRecords(SpreadsheetDocument doc)
    var metadata = doc.WorkbookPart.CellMetadataPart.Metadata;
    // Value metadata area
    ValueMetadata valueMetadata = metadata.AppendChild(new ValueMetadata());
    for (uint i = 0; i < NumCells; i++)
    // Type is 1-indexed, index into future metadata is 0-indexed
    var metadataBlock = valueMetadata.AppendChild(new MetadataBlock());
    var metadataRecord = metadataBlock.AppendChild(new MetadataRecord());
    metadataRecord.Val = i;
    metadataRecord.TypeIndex = (uint)1;
    /// <summary>
    /// Associate existing cells with existing metadata.
    /// </summary>
    /// <param name="doc">The document</param>
    private static void AssociateCellsWithMetadata(SpreadsheetDocument doc)
    for (uint i = 0; i < CellSpecs.Length; i++)
    var cellSpec = CellSpecs[i];
    var cell = GetCell(doc, cellSpec.Sheet, cellSpec.Column, cellSpec.Row);
    if (cell == null)
    throw new ArgumentException(string.Format("Cell {0} not found in row {1} of sheet {2}", cellSpec.Column, cellSpec.Row, cellSpec.Sheet));
    cell.ValueMetaIndex = i;
    /// <summary>
    /// Get a cell given the document, sheet name, column name and row index.
    /// </summary>
    /// <param name="doc">The document</param>
    /// <param name="sheetName">The sheet name</param>
    /// <param name="columnName">The column name</param>
    /// <param name="rowIndex">The row index</param>
    /// <returns>The cell</returns>
    private static Cell GetCell(SpreadsheetDocument doc, String sheetName, String columnName, uint rowIndex)
    var row = GetRow(doc, sheetName, rowIndex);
    if (row == null)
    throw new ArgumentException(string.Format("Row '{0}' not found", rowIndex));
    return row.Elements<Cell>().Where(c => c.CellReference.Value.StartsWith(columnName)).FirstOrDefault();
    /// <summary>
    /// Get a worksheet part by sheet name.
    /// </summary>
    /// <param name="document">The document</param>
    /// <param name="name">The sheet name</param>
    /// <returns>The worksheet part</returns>
    private static WorksheetPart GetWorksheetPartByName(SpreadsheetDocument document, string name)
    // Get Sheet by name from Sheets in Workbook
    var sheet = document.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>().Where(x => x.Name == name).FirstOrDefault();
    // Lookup WorksheetPart by Id
    return sheet == null ? null : (WorksheetPart)document.WorkbookPart.GetPartById(sheet.Id.Value);
    /// <summary>
    /// Get a row given the document, sheet name and row index.
    /// </summary>
    /// <param name="doc">The document</param>
    /// <param name="sheetName">The sheet name</param>
    /// <param name="rowIndex">The row index</param>
    /// <returns>The row</returns>
    private static Row GetRow(SpreadsheetDocument doc, String sheetName, uint rowIndex)
    var worksheetPart = GetWorksheetPartByName(doc, sheetName);
    if (worksheetPart == null)
    throw new ArgumentException(string.Format("Sheet '{0}' not found", sheetName));
    return worksheetPart.Worksheet.GetFirstChild<SheetData>().Elements<Row>().Where(r => r.RowIndex == rowIndex).First();
    struct CellSpec
    public string Sheet;
    public string Column;
    public uint Row;

    If you create a metadatatype with a single metdata block, and you reference that in your vm/cm cell attribute using a *one* based index, Excel seems to see the link and it honors it when saving the spreadsheet.
    So, I ended up with something like:
    <c ... cm="1"/> (I'm dealing with cell metadata, but the concept is equivalente to value metadata)
    <metadataTypes count="1">
      <metadataType name="MyMetaType" .../>
    </metadataTypes>
    <futureMetadata count="1" name="MyMetaType">
      <bk>
        <extLst><ext
    uri="http://example" xmlns:x="http://example"><x:val>87</x:val></ext></extLst>
      </bk>
    </futureMetadata>
    <cellMetadata count="1">
      <bk><rc
    t="1" v="0"/></bk> <!-- this is what gets referenced as cm=1 on the cell -->
    </cellMetadata>
    Hope this helps. 

  • Calculated Field is Disable while using PowerPivot to access multiple sheet column in a single pivot,

    Hi,
    I am trying to add a calculated field in my power pivot table to show the percentage on the basis of 2 columns, please let me know why this is not appearing and how can i fix it.
    Any other way if i can add a calculated field in the pivot table will be very helpful.
    Thanks
    Aman

    Thanks KR for the response,
    Yes I loaded multiple tables in the data model and using PoewrPivot ,
    i have a rating column, in that i have 0,1,2,3,4,5 rating numbers and we call it "Total expected occurrence",
    a single person can get same rating multiple times, if a person is getting >=4 rating no. we call it "Occurrence >= 4". now i have to find out the total
    count of "Occurrence >=4" for a particular person from "Total expected occurrence" column,
    once will get the  net "Occurrence >=4" for everyone, it should divide
     "Occurrence >=4"/ "Total expected occurrence" to take out the percentage of rating 4 for a particular person  
    Best Wishes,
    Aman verma

  • Export excel to Pivot table issue

    Hello Folks,
    Our Business user has a problem with the exporting to excel as Pivot table. Now, the user is trying to do, List - Export - Spreadsheet, and she is getting "Save XXL list object in  SAPoffice". How can we get the option to save in "Excel in XXL format" to get to the Pivot table..
    Thank You.

    hi,
    check out this [LINK|http://sample-code-abap.blogspot.com/2009/05/reset-alv-export-option-for-user.html]
    the report SALV_BS_ADMIN_MAINTAIN is used to reset this setting. It's easy, run the report, select and delete the record for the specific user from report output and that user will get the dialog again.

  • Send excel as Pivot table in attachment through ABAP

    Hi All,
    I have a requirement where I have to send excel file as attachment. Which I can do without any issue.
    But when we send in excel it should be in Pivot format as we can do in Excel.
    Sending excel file as attachment in Pivot format thorugh ABAP. Is it possible. If some one has tried it ever can tell me some thing about this.
    Thanks,
    Anu

    Hi Anu,
    can you pls share  the logic of sending excel as pivot table and i can try with it.
    Thank You.
    K.S.

  • Application uninstall bug of SCCM 2012 R2 with Cu2?

    I install SCCM 2012 R2, then Update to CU1, last moth I had updated to CU2
    I create two deployment type for winzip application.
    It is 'available' and not 'required'.
    Use script installer, it contains mst file. the script is vbs
    One is for x64, the other is for x86. all of them contains uninstall program(msiexec /x {code} /q)
    Install is ok
    But the uninstall button is grayed out.
    When I delete x86 deployment type then can uninstall this application
    It seem if it has more than one of deployment type, the uninstall button is grayed out
    I saw CU1 had fixed this bug, but why I met it again?  It is new bug of SCCM 2012 R2 CU2?
    I find R2 CU1 and R2 CU2 client update package in SCCM.
    Do I need to deploy them to all PC?
    If I use sccm OSD to install OS(Use default Configuration Manager Client Package), If I need to update Client in this client?

    Thanks, Narcoticoo & Torsten
    I also do the test, it is because I didn't push the update to client, I have some new questions about Update CU
    http://social.technet.microsoft.com/Forums/en-US/1b6161f4-2cdb-42a5-b59a-4b49970e2daf/how-to-update-cu1-cu2-to-sccm-2012-r2?forum=configmanagergeneral

  • Uable to do Excel native Pivots with SmartView

    Hi,
    I am running:
    Win7 64bit.
    Office 2010 32 bit.
    I am trying out the new functions of SmartView in 11.1.1.7. I have tried this on both a VM of V303 as well as two of Oracle's Internal servers running 1117.
    I can only get SmartView to function partially as I am unable to do Excel Native Pivots using SmartView. In addition to that I cannot get the "Mask Data" button to work either.
    What I am trying to do is described in this link.
    http://docs.oracle.com/cd/E37647_01/en/smartview/user/frameset.htm?ch15s05s02.html
    I have tried to reinstall SmartView. I have fully enabled all macro use. I have put the SmartView folder as "trusted" in Excel options.
    Have anybody tried anything similar?
    Any suggestions?
    /Mikke

    Bump...noone have tried anything like this???

  • Calculated Field formula not appearing in Power View Field List panel

    Hi,
    On Power View1 sheet of this
    workbook, the two PowerPivot calculated Field formulas (First Visit and First date of FY) are not appearing in the Power View Fields panel on the right hand side.
    I want to drag client and First Visit (calculated Field) to the Power View.
    Why is this happening?
    Regards, Ashish Mathur Microsoft Excel MVP www.ashishmathur.com

    I found a workaround for it - I was having the same problem as you. I wanted to display the last refresh date of my data, but Power View wouldn't display a date resulting from the [Last Refresh]=MAX(Date[Date]) formula.
    HOWEVER, a Pivot Table can handle that Calculated field just fine. So I renamed my measure "Refreshed Date" and added another tab in the Excel Sheet. I added a Pivot Table from PowerPivot into cell A1 and the only thing I put was that single
    measure (A2). To the right of that, I did =A2 and created an Excel Data Table. The title of that was "Last Refresh". Now, I could add that Data Table to the PowerPivot Model and into Power View. And then I hid that tab.
    The only downside to this method, is that if you're refreshing single tables at a time, you have to remember to refresh the Pivot Table when new data is added AND update the data in the model. I'm only connecting to one database, so I just choose
    "Refresh All" in Excel and it updates everything. It works perfectly! :)
    Well shoot, I even took a screenshot that helped explain everything, but it won't let me post it because my account isn't verified and it won't tell me how. If you have any questions, please let me know and I'll clarify!

  • Problem with Math In Calculated Fields

    I am calculating a group incident rate for data returned from
    a query. The formula is Number of cases multiplied by 200000
    divided by number of hours worked. Cases in my report is the
    calculated field: calc.CaseSum (the sum of cases for the group)
    Hours is calc.SumHours (the sum of hours for the group). The actual
    values for these variables (for the first group are 48 and 29427171
    respectively. When I create the following calculated field called
    rate using the formula: (calc.CaseSum * 200000) / calc.SumHours,
    Cold Fusion Generates a Runtime Error:
    Invalid ColdFusion expression in report. If the expression is
    a string, ensure that it is within quotes. Error: (calc.CaseSum *
    200000) / calc.SumHours is not a valid ColdFusion expression.
    If I use the constant value "29427171" as the divisor, the
    report works albeit only for the first group. Any ideas; is this a
    bug, or am I misusing the product?
    Addition: I forgot to mention I am using CF8. Also this
    formula worked fine as a Report Total before I introduced grouping
    and modified the calculated fields to reset on the change of a
    group.

    Sorry, I've been on another project for awhile. This problem
    will certainly be a "show stopper" for me if I cannot resolve it.
    As I mentioned in my original post, I used a constant in the
    formula in lieu of the variable and the calculation worked. This
    would suggest that CF does not have a problem with a large number.
    In spite of that reasoning, I tried Tony's suggested (thanks
    by the way!) with the identical outcome, only difference is the new
    formula is displayed in the error message.
    Tony, you also suggested that I set the variables using
    CFSET... How would I do this within the report writer environment.
    I had tried a similar approach: to perform half the calculation
    i.e. that within the parenthesis, and assign that value to a
    separate "calculated field: and then perform the rest of the
    calculation on that variable with the same outcome.
    I think that I may be dealing with a CF bug here, I'd like to
    find a workaround... I've noticed that CF8 has a new patch, perhaps
    after I apply it, I may be able to get this thing to work. I'm on
    another project right now so it will be a few days before I can
    test this theory, I report the result.
    Should this fail, and no one can come up with a workaround, I
    will report this to Adobe.

Maybe you are looking for

  • ITunes wont reconize my iPod but my iPhone works fine - VISTA

    I know what you are saying...go through the 5 R's and all will be well. NO, this is the weirdest thing I've ever encountered. I just got this HP Laptop a couple of months ago...it has Vista installed on it. I downloaed iTunes 7.4 when I got my iPhone

  • In-ear monitor recommendations?

    I'd prefer to use an in-ear monitor (so I can have a click playing mainly...). Does anyone have recommendations. I've never used one so I am at square one right now. Any help is very appreciated!

  • The iOS update crashed my phone.  What do I do?

    My phone just lays there like a dead fish after the update.  What do I do to restore it?

  • Opening CS5 projects in CS4?

    Im still using AE CS4 and I'm trying to work on a project with someone using CS5, but I'm unable to open his .aep. Is there a way for him to save his CS5 project so that it can CS4 can open it?

  • Assigning Privilege Level Thru RADIUS

    I'm using Microsoft IAS as my RADIUS server. We have a number of Cisco 2800 routers running the latest IOS which are also acting as VPN servers for our remote user connecting using their laptops via IPSec and Cisco VPN Client. How can I set the privi