Calculate percrentage based on a distinct value

Hi every one,
I am trying to compute a percentage from a table which have got a strange format.
here my example:
ID
Tribune
Total
Nomber
110
TRIBUNE OUEST
      49 833  
505
110
TRIBUNE OUEST
      49 833  
37
110
TRIBUNE OUEST
      49 833  
99
110
TRIBUNE OUEST
      49 833  
79
25%
110
TRIBUNE OUEST
      49 833  
307
9%
110
TRIBUNE OUEST
      49 833  
589
110
TRIBUNE OUEST
      49 833  
1 247
110
TRIBUNE OUEST
      49 833  
1 213
110
TRIBUNE OUEST
      49 833  
545
114
TRIBUNE OUEST
54 000
991
114
TRIBUNE OUEST
54 000
518
114
TRIBUNE SUD
54 000
67
114
TRIBUNE SUD
54 000
953
114
TRIBUNE SUD
54 000
1 140
110
TRIBUNE SUD
      49 833  
1 302
110
TRIBUNE SUD
      49 833  
960
110
TRIBUNE SUD
      49 833  
1 291
110
TRIBUNE SUD
      49 833  
1 293
110
TRIBUNE SUD
      49 833  
771
110
TRIBUNE SUD
      49 833  
639
114
TRIBUNE EST
54 000
1 361
110
TRIBUNE EST
49 833
1 497
So I have in my case ID which represent an event (here 110 and 114)
For one ID there are many times the same number in the column "Total" which represent the total of place of the event. 
!!! It is not the sum of each "Tribune" for instance for 110 the total places is 49833 and not 49833 * number of lines. !!!
Same thing for others ID.
The problem is, because of this, I cannot do divid(sum(total);sum(Nomber)) to get my percentage. Have any ideas how can take just one time the value in the column "total" ?
Regards,
Mijo

You need to provide an example of your use case. This formula will work for the detail rows of a pivot table with ID or Tribune on rows/columns. It's very difficult to provide help without a detailed understanding of how a measure will be used, as everything
is context-dependent.
If you will be creating a pivot table without [ID] or [Tribune] on rows/columns, or you need totals to behave properly, then try this:
Percentage:=
DIVIDE(
SUM( <table name>[Nomber] )
, SUMX(
DISTINCT( <table name>[Tribune] )
, MAX( <table name>[Total] )

Similar Messages

  • Calculate percrentage based on 2 column and one filter

    Hi,
    I am looking for a way to compute percentage based one two column and 1 filter but i have a problem when every thing is checked on my filter.
    The table as follow is my example:
    ID
    cat1
    cat2
    number
    total
    pct
    1
    a
    aa
    5
    40
    13%
    1
    a
    ab
    20
    40
    50%
    1
    a
    ac
    15
    40
    38%
    1
    b
    ba
    12
    47
    26%
    1
    b
    bb
    20
    47
    43%
    1
    b
    bc
    15
    47
    32%
    2
    a
    aa
    9
    45
    20%
    2
    a
    ab
    16
    45
    36%
    2
    a
    ac
    20
    45
    44%
    2
    b
    ba
    10
    50
    20%
    2
    b
    bb
    20
    50
    40%
    2
    b
    bc
    20
    50
    40%
    I create a power table as follow:
    Filter: column ID
    Axis: cat1 and cat2
    values: pct
    The problem is when I want to select all my data in my filter, a sum/mean is done for pct but the results are wrong. Did I missed something ? Is there a way to correct the problem ?

    Hi mi jo,
    It appears that you have created your percentage as a Calculated Column and what you actually want is a Calculated Field.
    You can create a Calculated Field by clicking on the Power Pivot ribbon and using a DAX formula similar to the following:
    Percentage:=DIVIDE(SUM(TableName[number]), SUM(TableName[total]))
    I have formatted this Calculated Field as a percentage and used it to create a Pivot Table:
    Is this what you were after or have I misunderstood the problem?
    Edit: Just took a quick look at the workbook and can see that the pct column is coming in as a fixed value for a row. The above solution should help. A best practice would be to first create a Calculated Field for each of the number and
    total columns such as...
    Sum of Number:=Sum(TableName[number])
    And...
    Sum of Total:=Sum(TableName[total])
    And then finally update this DAX formula:
    Percentage:=DIVIDE(SUM(TableName[number]), SUM(TableName[total]))
    To this...
    Percentage:=DIVIDE([Sum of Number], [Sum of Total])
    Regards,
    Michael Amadi
    Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to vote it as helpful :)
    Website: http://www.nimblelearn.com
    Blog: http://www.nimblelearn.com/blog
    Twitter: @nimblelearn

  • Sum rows of Column A based on distinct values of Column B

    Hello everyone,
    below is my xml
    <ROWSET>
    <ROW>
    <ORDER_NO>103-4385509</ORDER_NO>
    <SITE_NO>103</SITE_NO>
    <ORDER_ID>4385509</ORDER_ID>
    <CUSTOMER_ID>2676832</CUSTOMER_ID>
    <TAX_AMOUNT>.33</TAX_AMOUNT>
    <CREATED_DATE>08/20/2010</CREATED_DATE>
    <USER_CREATED>TSDAL671</USER_CREATED>
    <Delivery_Method>CARRY OUT STORE</Delivery_Method>
    <Entered_By>TSDAL671</Entered_By>
    <SKU_NO>321182</SKU_NO>
    <NAME_TEXT>MGR_OVERRIDE</NAME_TEXT>
    <ATTRIBUTE_ID>319</ATTRIBUTE_ID>
    <ATTRIBUTE_VALUE>Override Done</ATTRIBUTE_VALUE>
    <DETAIL_SEQ_NO>1</DETAIL_SEQ_NO>
    </ROW>
    <ROW>
    <ORDER_NO>103-4385509</ORDER_NO>
    <SITE_NO>103</SITE_NO>
    <ORDER_ID>4385509</ORDER_ID>
    <CUSTOMER_ID>2676832</CUSTOMER_ID>
    <TAX_AMOUNT>.33</TAX_AMOUNT>
    <CREATED_DATE>08/20/2010</CREATED_DATE>
    <USER_CREATED>TSDAL671</USER_CREATED>
    <Delivery_Method>CARRY OUT STORE</Delivery_Method>
    <Entered_By>TSDAL671</Entered_By>
    <SKU_NO>321182</SKU_NO>
    <NAME_TEXT>OEDTL_TAX_INFO</NAME_TEXT>
    <ATTRIBUTE_ID>314</ATTRIBUTE_ID>
    <ATTRIBUTE_VALUE>441130760|441130760|441130760|1|1|1|20100820|2676832|2|SPARTS|</ATTRIBUTE_VALUE>
    <DETAIL_SEQ_NO>1</DETAIL_SEQ_NO>
    </ROW>
    <ROW>
    <ORDER_NO>103-4385509</ORDER_NO>
    <SITE_NO>103</SITE_NO>
    <ORDER_ID>4385509</ORDER_ID>
    <CUSTOMER_ID>2676832</CUSTOMER_ID>
    <TAX_AMOUNT>.18</TAX_AMOUNT>
    <CREATED_DATE>08/20/2010</CREATED_DATE>
    <USER_CREATED>TSDAL671</USER_CREATED>
    <Delivery_Method>CARRY OUT STORE</Delivery_Method>
    <Entered_By>TSDAL671</Entered_By>
    <SKU_NO>412679</SKU_NO>
    <NAME_TEXT>OEDTL_TAX_INFO</NAME_TEXT>
    <ATTRIBUTE_ID>314</ATTRIBUTE_ID>
    <ATTRIBUTE_VALUE>441130760|441130760|441130760|1|1|1|20100820|2676832|2|0035|</ATTRIBUTE_VALUE>
    <DETAIL_SEQ_NO>2</DETAIL_SEQ_NO>
    </ROW>
    i have to display 3 rows but while doing sum of TAX_AMOUNT grouped by ORDER_ID, i need to sum only for 2 records based on the distinct value of DETAIL_SEQ
    so my output should be some thing like below
    ORDER_ID|TAX_AMOUNT|DETAIL_SEQ|ATTRIBUTE_ID
    4385509|0.33|1|319
    4385509|0.33|1|314
    4385509|0.18|2|314
    SUM = 0.51
    Note : i cannot do distinct in the sql becuase attribute_id is different for same DETAIL_SEQ_NO.
    I tired doing <?sum([xdoxslt:distinct_values(current-group()/DETAIL_SEQ_NO)]/TAX_AMOUNT)?>
    it didn't work.
    Can anyone please help me!!
    Thanks in Advance!!

    That syntax wont work.
    One method of doing.
    <?for-each-group:/ROWSET/ROW;ORDER_NO?>
    <?for-each:current-group()?>
    <?ORDER_NO?>  <?TAX_AMOUNT?>  <?DETAIL_SEQ?>  <?ATTRIBUTE_ID?>
    <?end for-each?> <?xdoxslt:set_variable($_XDOCTX,'sum_attr',0)?>
    <?for-each-group:current-group();DETAIL_SEQ_NO?>
    <?xdoxslt:set_variable($_XDOCTX,'sum_attr', xdoxslt:get_variable($_XDOCTX,'sum_attr')+ TAX_AMOUNT)?>
    <?end for-each?><?xdoxslt:get_variable($_XDOCTX,'sum_attr')?>
    <?end for-each?>

  • Select records based on first n distinct values of column

    I need to write a query in plsql to select records for first 3 distinct values of a single column (below example, ID )and all the rows for next 3 distinct values of the column and so on till the end of count of distinct values of a column.
    eg:
    ID name age
    1 abc 10
    1 def 20
    2 ghi 10
    2 jkl 20
    2 mno 60
    3 pqr 10
    4 rst 10
    4 tuv 10
    5 vwx 10
    6 xyz 10
    6 hij 10
    7 lmn 10
    so on... (till some count)
    Result should be
    Query 1 should result --->
    ID name age
    1 abc 10
    1 def 20
    2 ghi 10
    2 jkl 20
    2 mno 60
    3 pqr 10
    query 2 should result -->
    4 rst 10
    4 tuv 10
    5 vwx 10
    6 xyz 10
    6 hij 10
    query 3 should result -->
    7 lmn 10
    9 .. ..
    so on..
    How to write a query for this inside a loop.

    Hi,
    So, one group will consist of the lowest id value, the 2nd lowest and the 3rd lowest, reggardless of how many rows are involved. The next group will consist of the 4th lowest id, the 5th lowest and the 6th lowest. To do that, you need to assign numbers 1, 2, 3, 4, 5, 6, ... to the rows in order by id, with all rows having the same id getting the same number, and without skipping any numbers.
    That sounds like a job for the analytic DENSE_RANK function:
    WITH     got_grp_id     AS
         SELECT     id, name, age
         ,     CEIL ( DENSE_RANK () OVER (ORDER BY id)
                   / 3
                   )          AS grp_id
         FROM     table_x
    SELECT     id, name, age
    FROM     got_grp_id
    WHERE     id     = 1     -- or whatever number you want
    ;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
    See the forum FAQ {message:id=9360002}

  • Oracle UCM distinct values for attribute in GET_SEARCH_RESULTS ResultSet

    hi, can anyone, please, tell if there is a way to get a distinct values of resultset of GET_SEARCH_RESULTS?
    I mean, is it possible to obtain distinct values with custom where values of attribute through api?
    I need to build somewhat like autosuggest feature, but afaik there is no such service.
    Alternatives are
    - build my own service which can accept query text, pass it to GET_SEARCH_RESULTS, get results, calculate distinct and output it in hda - i dont like this idea, becouse it means getting whole result set into java while it is efficient to handle in DB
    - customize CHECK_IN/UPDATE services to update cached distincts (that means no grouping on custom queries)
    May be there was some sort of discussion or blog note?
    Thanks in advance.

    If you do not declare "SearchEngineName" as part of the request, whatever value is defined in config.cfg is used. This behavior is by design.
    Setting it in your request allows you to override the system setting in order to use another search engine, provided that the rest of the underlying parts are in place for the engine you are trying to use. For example, if your system setting is "DATABASE.METADATA", setting your individual request to "ORACLETEXTSEARCH" will probably fail, since the Oracle full text indexes would not exist. But if you are doing just metadata searching based on a couple of columns, and don't need the full text part for the request, it's a good way to craft a very specific search. Combined with a couple of database indexes on the columns in the where clause, it's also a good performer.
    I do "SearchEngineName=DATABASE" usually in conjunction with the parameter "SearchQueryFormat=Native" so I can create some database specific queries in native SQL (and thus avoiding the need to figure out the exact internet or universal syntax.) Your mileage may vary.

  • How to create a table with distinct values ?

    I want to create a new table based on an existing table distinct values only, how can I avoid to create the duplicate values ?
    e.g.
    table1
    field1 field2
    0001 ABD
    0001 ABD
    0002 DCF
    0002 DCF
    new table
    field1 field2
    0001 ABD
    0002 DCF
    thanks

    create table table2
    as
    select distinct field1,field2
    from table1

  • CFM /TR - how system calculate amount based on rate FX 60A

    Hi all,
    i need to know how system calculates amount based on rate entered upon creating a contract (t-code TX01).
    steps input:-
    1. header - comp code, product type, trans type
    2. partner
    3. purchase curr & amount (eg. IDR 8,345,545,500)
    4. sale currency only (amount system will auto calculate) USD
    5. rate field = 11.553
    6. spot rate will auto pick up from rate
    7. value date
    8. contract date
    upon TBB1 no error. posting log as follows:-
    FX1000+ : 40 8,345,545,500 IDR bank GL acc
                    50 8,345,545,500 IDR clearing acc
    FX2000- : 40 722370.42 USD clearing acc
                   50 722370.42 USD bank GL acc
    but upon TPM18 error occurred as follows:
    DBT_C009 - GL not maintain in acc symbol 5.3.4
    DBT_E039 - no posting spec assigned to update type
    DBT_B018 : 40 0 USD, 431,977,511 IDR gain/loss
                       50 0 USD, 431,977,511 IDR clearing acc
    so, after maintained DBT_C009 as follows still error for DBT_E039:
    40  0 USD, 38 IDR clearing acc
    50  0 USD, 38 IDR P&L gl acc
    what i don't understand is how system calculate and get DBT_C009 & DBTE039.
    what is the function of TPM18?
    thanks.

    Hello Prarnod,
    I have done the first node only for actuals that come from the integration to the internal order.
    I have tried setting up 2 and 3 even though the 3rd one does not make any sense to me
    Thanks,
    Paul

  • Sorting a column does not result in distinct values on Dashboard prompts

    Hi,
    We have a period column, the records of which are 'JAN-02' , "FEB-02"...."DEC-09". We need sort this column in descending order in Dashboard Prompts. We have another column "Date", which has been used to sort the period column. To achieve this in descending order, we have converted Show Results from “All Values” to “SQL Results” in dashboard prmpts, then entered the below sql.
    SELECT "CODE COMBINATIONS"."LINE AC PERIOD" FROM INVOICE_PAYMENTS
    order by "CODE COMBINATIONS"."LINE AC DATE" desc
    The above sql resulted in non-distinct values as below. Using distinct in the above sql throws syntax error.
    Period
    JAN-09
    JAN-09
    JAN-09
    FEB-09
    FEB-09
    How do we get distinct values and in descending order??
    Thanks and appreciate any ideas
    Surya

    Go to advanced tab and check "Use distinct clause" that will fire a distinct to the query.
    In the rpd month logical column , there is an option called sort order in the general properties and you need to specify the date column if you need to sort it based on the date column and in the Answers you can simply enable Descending sort order on the same column. That should take care of it
    Hope it helps
    Thanks
    Prash

  • Using Shading Dictionary to perform shading in pdf,before that the shading dictionary call from Pattern Dictionary.In the Pattern Dictionary there is an Matrix based on the matrix value  location the shading operatihow the axial shading is preserve in pdf

    using Shading Dictionary to perform shading in pdf,before that the shading dictionary call from Pattern Dictionary.In the Pattern Dictionary there is an Matrix based on the matrix value  location the shading operation is perform,So i dont know how to calculate value of pattern Dictionary matrix value.
    10 0 obj
    << /Type /Pattern
    /PatternType 2
    /Shading 11 0 R
    /Matrix [1.00 .00 .00 1.00 54.00 53.00]  // the matrix value how to calculate
    >>
    11 0 obj
    <<
    /ColorSpace /DeviceRGB
    /Function 12 0 R
    /ShadingType 2
    /Coords [109.2726 69.00 109.2726 .00]
    /Extend [true true]
    >>
    12 0 obj
    <<
    /FunctionType 0
    /Domain [.00 1.00]
    /Range [.00 1.00 .00 1.00 .00 1.00]
    /Size [1002]
    /BitsPerSample 8
    /Length 3006
    >>
    stream
    here is an stream of colors
    endstream
    endobj
    Can anybody help me please.
    Regards, Sasi kumar sekar.

    Hi, Sasi -
    The Matrix maps coordinates in your shading dictionary into User Space. That is, the Matrix entry in the Pattern dictionary specifies a coordinate transformation that will be applied to coordinates specified in the shading dictionary.
    To take your example, you have an axial shading extending from (rounding off) 109,69 to 109,0.  Your Pattern dictionary specifies the Matrix
    [ 1  0  0  1  54  53 ]
    This transformation matrix corresponds to a scale of 1,1 (that is, no change in scale) and a translation of 54,53. Thus, the actual endpoints for the axial shading will be the User Space positions 163,122 and 163,53 (assuming I’ve added correctly).
    As to what values to use for your Matrix, it depends on how you’ve set up your Shading dictionary. If the coordinates you’ve specified are actually where you want the gradient to go, then just use an identity matrix
    [ 1  0  0  1  0  0 ]
    By the way, are you sure that the Pattern dictionary includes a Matrix entry? I seem to remember (it's been a while since I've looked at Patterns) that the matrix is supplied as an argument to the makepattern operator:
    <<patternDict>> [ 1 0 0 1 0 0 ] makepattern
    Hope that helps.
    - John Deubert
      Acumen Training
      PostScript and PDF
      Training & Consulting

  • Distinct values in each column

    Hi
    I have a table with three columns and I would like to display distinct values in each column. Could any one please help me to get the output.
    col1     col2     col3
    ====     ====     ====
    a     1     x     
    a     2     y
    a     3      z
    a     4      u
    b     5      v
    b     6      x
    b     7      x
    b     9      x
    b     10     y
    b     11     y
    b     12     y
    b     13     y
    b     14     x
    b     15     y
    b     16     z
    b     17     u
    b     18     v
    b     19     x
    b     20     x
    c     21     x
    c     22     y
    c     23     y
    c     24     y
    c     25     y
    c     26     x
    c     27     y
    c     28     z
    Output needed
    ===========
    col1     col2     col3
    ====     ====     ====
    a     1     x
    b     2     y
    c     3     z
         4     u
         5     v
         6
         7
         9
         10
         11
         12
         13
         14
         15
         16
         17
         18
         19
         20
         21
         22
         23
         24
         25
         26
         27
         28
    Thanks
    Vasanth

    but the only drawback - you need to know the column, comprising the biggest amount of distinct values beforehand.No. There is no any difference in which column will be chosen as "based".
    For demo purposes I've added extra row number column to show full generality and symmetry of the approach:
    exec dbms_random.seed(0)
    with t as ( select chr(ascii('a') + dbms_random.value(0, 3)) as c1,
                       trunc(dbms_random.value(1, 20))           as c2,
                       chr(ascii('u') + dbms_random.value(0, 6)) as c3
                  from dual connect by level <= 20
       tt1 as ( select lag(          null,  1, c1) over (partition by c1 order by null) as c1,
                       lag(to_number(null), 1, c2) over (partition by c2 order by null) as c2,
                       lag(          null,  1, c3) over (partition by c3 order by null) as c3
                  from t
       tt2 as ( select tt1.*,
                       row_number() over (order by c1) as rn1,
                       row_number() over (order by c2) as rn2,
                       row_number() over (order by c3) as rn3,
                       rownum rn
                  from tt1
       tt3 as ( select case when rn1 > rn
                            then last_value(c1) over (order by rn1 range between abs(rn1 - rn) preceding
                                                                             and abs(rn1 - rn) preceding)
                            else last_value(c1) over (order by rn1 range between abs(rn - rn1) following
                                                                             and abs(rn - rn1) following)
                       end as c1,
                       case when rn2 > rn
                            then last_value(c2) over (order by rn2 range between abs(rn2 - rn) preceding
                                                                             and abs(rn2 - rn) preceding)
                            else last_value(c2) over (order by rn2 range between abs(rn - rn2) following
                                                                             and abs(rn - rn2) following)
                       end as c2,
                       case when rn3 > rn
                            then last_value(c3) over (order by rn3 range between abs(rn3 - rn) preceding
                                                                             and abs(rn3 - rn) preceding)
                            else last_value(c3) over (order by rn3 range between abs(rn - rn3) following
                                                                             and abs(rn - rn3) following)
                       end as c3
                  from tt2
    select c1, c2, c3 from tt3
      where c1 || c2 || c3 is not null
      order by c1, c2, c3
    C1            C2 C3
    a              1 u
    b              3 v
    c              4 w
                   5 x
                   7 y
                   8 z
                   9
                  11
                  13
                  15
                  16
                  17
                  19
    13 rows selected.P.S. Thanks to [url http://www.sql.ru/forum/actualthread.aspx?bid=3&tid=482506&hl=over+range#4785373]Vladimir Sitnikov for the demo of the approach.

  • Looking for help with javascript to autofill checkboxes based on a numeric value.

    I have a numeric field that I would like to have 1 - checkbox
    out of five autofilled based on a numeric value.
    For instance the numeric value is TotalPoints
    If the TotalPoints Value is >10 autofill this checkbox
    If the TotalPoints Value is 10 - 19 autofill this checkbox
    If the TotalPoints Value is 20 - 49 autofill this checkbox
    If the TotalPoints Value is 50 - 69 autofill this checkbox
    If the TotalPoints Value is 70+ autofill this checkbox
    Assistance in writing the correct script for this would be greatly appreciated.

    All the checkboxes have separate names. 
    Check box #1 is AssetClass.0 with the export value of 1
    Check box #2 is AssetClass.1 with the export value of 2
    Check box #3 is AssetClass.2 with the export value of 3
    Check box #4 is AssetClass.3 with the export value of 4
    Check box #5 is AssetClass.4 with the export value of 5
    Score and StrategyUse the following calculation to determine your point score and indentify the appropriate strategy listed below.A. Add your points for questions 1 – 2.
    B. Add your points for questions 3 – 12.
    C. Subtract B from A. (Numeric Text Box)  name is TotalPoints
     Points Strategy Asset Class Mix (check boxes as named above)
     0 – 10 Primarily Fixed Income: 80% Fixed Income; 20% Equity
    10 – 19 Balanced Fixed Income-Oriented: 60% Fixed Income; 40% Equity
    20 – 49 Balanced Equity-Oriented: 40% Fixed Income; 60% Equity
    50 – 69 Primarily Equity: 20% Fixed Income; 80% Equity
    70+ Equity: 95%; 5% Cash 

  • How to get distinct values from a list and display in a ListView webpart.

    Hi,
    I have a requirement in which I need to pull unique/distinct values from a custom list and then display it via a listview webpart. Can any one suggest how this can be done.
    If possible please share the CAMEL query to fetch distinct values from a custom list.
    Thanks,
    Ankit

    Hi Ankit,
    Is there any particular reason that the values need to be shown in a list view web part?  Are you going to use that web part for filtering via web part connections?
    I ask because the enterprise site collection features include the SharePoint List Filter web part, which may accomplish what you're looking for.
    If you just need to display the values in a grid view, you might have more luck with the JavaScript Client Object Model.  Try putting the following in a text file:
    <style>
    .CustomTableClass{display:table;table-layout:fixed}
    .CustomRowClass{display:table-row;}
    </style>
    <div id="distinct_values_div" class="CustomTableClass">
    <img src="/_layouts/loading.gif" />
    </div>
    <script language="JavaScript" type="text/JavaScript">
    var siteUrl = '/sitecollection/web'; //use the actual subsite URL here
    var listName = 'mylist'; // use the actual list name here
    var field = "Title" // use the actual field you want to display here
    var divToUpdate = document.getElementById("distinct_values_div");
    var rowClass = "CustomRowClass";
    ExecuteOrDelayUntilScriptLoaded(function(){
    var clientContext = new SP.ClientContext(siteUrl);
    var web = clientContext.get_web();
    var lists = web.get_lists();
    var list = lists.getByTitle(listName);
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query></Query><RowLimit>500</RowLimit></View>');
    this.collListItem = list.getItems(camlQuery);
    clientContext.load(collListItem,"Include ("+field+")");
    clientContext.executeQueryAsync(
    Function.createDelegate(this, this.onQuerySucceeded),
    Function.createDelegate(this, this.onQueryFailed));
    },"sp.js");
    function onQueryFailed(sender, args){
    divToUpdate.innerHTML = 'Unable to retrieve values: '+args.get_message());
    function onQuerySucceeded(sender, args){
    var allValues = [];
    var listItemEnumerator = collListItem.getEnumerator();
    divToUpdate.innerHTML = "";
    while(listItemEnumerator.moveNext()){
    var listItem = listItemEnumerator.get_current();
    if(!containsString(allValues,listItem.get_item(field)){
    var value = listItem.get_item(field);
    allValues.push(value);
    var newDiv = document.createElement("div");
    newDiv.className = rowClass;
    newDiv.innerHTML = value;
    divToUpdate.appendChild(newDiv);
    function containsString(strArray, text){
    var contains = false;
    for (var i=0; i<strArray.length; i++){
    if(strArray[i]==text){contains = true; break;}
    return contains;
    </script>
    Upload the text file to a library on the site, then add a content editor web part to a page where you want the distinct values to appear. In the content editor web part's properties, edit the Content Link so that it links directly to the text file.  This
    will cause the JavaScript to run on the page.

  • Get distinct values from a coma seperated string variable

    Hi ,
    I am getting an comma seperated string as in parameter, now i want to get the distinct values from that string and will use those values to pass it to a query.
    any help

    try this:
    sorry about the messiness - it's just quickly copied from some badly formatted code....
    TYPE T_FieldArray IS TABLE OF varchar2(255) INDEX BY BINARY_INTEGER;
    function SPLIT_CSV_FIELDS (
    p_Input_Str in varchar2,
    p_Delimiter in varchar2,
    p_Quote_Char in varchar2)
    return t_fieldarray is
    v_FieldArray T_FieldArray;
    v_input_str varchar2(4000);
    v_field_str varchar2(255);
    v_pos number;
    e number := 0;
    v_delim_str varchar2(3);
    cur_pos number;
    begin
    loop
    -- find each delimiter char in string
    v_pos := INSTR(v_input_str, p_Delimiter);
    -- each time delimiter char is found
    if v_pos > 0 then
    -- current field value is current string to position prior to delimiter char
    v_field_str := UPPER(SUBSTR(v_input_str, 1, v_pos - 1));
    -- remove quote char from end of field (if any)
    v_field_str := TRIM(TRANSLATE(v_field_str, NVL(p_Quote_Char, p_Delimiter), ' '));
    -- increment element number
    e := e + 1;
    -- get remainder of input string to check
    v_input_str := SUBSTR(v_input_str, v_pos + 1, LENGTH(v_input_str) - v_pos);
    v_FieldArray(e) := v_field_str;
    else
    -- increment element number
    e := e + 1;
    -- last field value is what's left of input string less quote char (if any)
    v_field_str := TRIM(TRANSLATE(UPPER(v_input_str), NVL(p_Quote_Char, p_Delimiter), ' '));
    v_FieldArray(e) := v_field_str;
    exit;
    end if;
    end loop;
    return v_FieldArray;
    end;

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

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

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

  • Get distinct values from plsql array

    Hi,
    I have declared a variable as below in plsql proc.
    type t_itemid is table of varchar2(10);
    inserted set of items in to this using a program
    now i want distinct values from that array how can i get it.

    I am using 9i so i cannot use set operator and more over my problem is that i am declaring the variable inside the plsql block . when i tried i am getting the below errors:
    SQL> r
    1 declare
    2 type t_type is table of varchar2(10);
    3 v_type t_type;
    4 begin
    5 v_type := t_type('toys','story','good','good','toys','story','dupe','dupe');
    6 for i in (select column_value from table(v_type)) loop
    7 dbms_output.put_line(i.column_value);
    8 end loop;
    9* end;
    for i in (select column_value from table(v_type)) loop
    ERROR at line 6:
    ORA-06550: line 6, column 41:
    PLS-00642: local collection types not allowed in SQL statements
    ORA-06550: line 6, column 35:
    PL/SQL: ORA-22905: cannot access rows from a non-nested table item
    ORA-06550: line 6, column 10:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 7, column 22:
    PLS-00364: loop index variable 'I' use is invalid
    ORA-06550: line 7, column 1:
    PL/SQL: Statement ignored

Maybe you are looking for

  • Unused Objects Content Report runs forever

    Dear Portal Gurus we have a lot of content in our portal (thousands of objects created by us) The main part is from uploading the ERP Roles into the portal. Our guess is, that quite a bit is not used at all. It seems that the two "Unused Objects" rep

  • Animated gif frame count & fps

    How do I find out details of an animated gif? I need to know the number of images in a strip, and also the frame rate. I would like to convert the strip to a BufferedImage for animation.

  • Trubble with aperture after the latest update

    i cant open aperture after the latest update

  • F.5D Error Message

    Hi Experts, When we executing F.5D for calculate balance sheet adjustment we are getting below message C.Code      Account            Diagnosis  1001           130120             Records not carried forward since no account defined  - > Check A/C   1

  • IPhone Photo Album - How To...

    Hi guys, In iPhoto I can see the name of the pictures and search them by name. But in the iPhone photo album I cannot see the name of the pictures. Any way to see them? I need to see pictures by name as I'm creating different picture folders for plan