Counting all the rows in a table

I've just come across what I think is a big oversight in the Power Query UI: it doesn't seem to be possible to find the total number of rows in a table using just the functionality available in the UI. I can do this very easily if I write my own expression
using Table.RowCount(), but I would have expected to be able to do this through the UI. At the moment, when I go to the Group By dialog (which is where I'd expect to be able to do this) and delete all the columns in the Group By section the OK button gets
greyed out. 
Am I missing something here?
Chris
Check out my MS BI blog I also do
SSAS, PowerPivot, MDX and DAX consultancy and run
public SQL Server and BI training courses in the UK

Hi Miguel,
No, what I was talking about was to be able to use the Group By dialog and have no column to group by - that's to say, I'd just want to be able to count the number of rows in a table (or return the sum of all values in a column, or the min/max etc) and return
a single value. I know I could do this by inserting an artificial column that only contains one distinct value, and using that in the Group By, or by writing my own expression that uses Table.RowCount(), but it seems like a very basic operation that should
be easier to do in the UI.
Chris
Check out my MS BI blog I also do
SSAS, PowerPivot, MDX and DAX consultancy
and run public SQL Server and BI training courses in the UK

Similar Messages

  • Procudure to count all the rows in a all tables in the schema

    When I run the following store procedure to count all the rows in all the tables I crash my sql Plus editor:
    CREATE OR REPLACE PROCEDURE TC_TABLEROWCOUNT(OWNER IN varchar2)
    IS
    row_count number;
    cursor get_tab is
    select table_name, num_rows
    from all_tables
    where owner='MAXDEV';
    begin
    dbms_output.put_line('Checking Record Counts for schema maxdev ');
    FOR get_tab_rec IN get_tab LOOP
         BEGIN
              EXECUTE IMMEDIATE 'select count(*) from '||get_tab_rec.table_name
              INTO row_count;
              EXCEPTION WHEN OTHERS THEN
                        dbms_output.put_line('Error counting rows for table '
                                                 ||get_tab_rec.table_name);
         END;
    END LOOP;
    END;
    What am I doing wrong.
    Thanks for any help Tony

    The boss gave me 5 pages of tables and wants to know how many row there are in each table. There is a problem of one DB being out of sync with another.
    But I have managed to work the problem though.
    here is the working code:
    CREATE OR REPLACE PROCEDURE TC_TABLEROWCOUNT (
    TableOwner IN varchar2)
    IS
    row_count number;
    vTable varchar2(30);
    v_sqlstmt varchar2(100);
    cursor get_tab is
    select table_name, num_rows
    from all_tables
    where owner = TableOwner;
    begin
    dbms_output.put_line('Checking Record Counts for schema maxdev ');
    FOR get_tab_rec IN get_tab LOOP
    vTable := get_tab_rec.table_name;
    v_sqlstmt := 'SELECT count(*) from '||vTable;
    EXECUTE IMMEDIATE v_sqlstmt into row_count;
    dbms_output.put_line('Table '|| get_tab_rec.table_name || ' Row ' || row_count);
    END LOOP;
    END;

  • Query from oracle to MySql using dblink fetch all the rows in MySql table

    Hello,
    I am using Heterogeneous connectivity between oracle 10204 to Mysql database.
    I have a database link in the oracle side .
    I am query a table in MySql that have 10 million rows.
    Its doesnt matter if i am running :
    select * from "CDR_Accounts"@mysql where "id"=7675405;
    or
    select * from "CDR_Accounts"@mysql ;
    There is an index on the id column.
    Yet, it seems that the Mysql is feteching all the rows from the table , all the data is transfering to oracle over the dblink , and only after that the requested rows are get back to the client.
    The /etc/odbcinst.ini file is as follow:
    [odbcprd:oracle@odbc /software/oracle]$ cat /etc/odbcinst.ini
    [myodbc3]
    Description             = Mysql connector to mysql version 3.5
    Driver          = /software/oracle/MysqlOdbc/3.52/lib/libmyodbc3-3.51.25.so
    Driver64                = /usr/lib
    Setup           = /software/oracle/MysqlOdbc/3.52/lib/libmyodbc3S-3.51.25.so
    Setup64         = /usr/lib
    UsageCount              = 1
    CPTimeout               = 3600
    CPReuse         = Please advice
    Thanks

    When using a gateway it is always possible that a where clause is not sent to the remote database. This is called post processing and depends on several factors like the used ODBC driver, the columns and its data types but also if you specify certain functions in the where clause.
    The fastest way to see if post processing happens is in Oracle 11g the explain plan for a query. In 10g the plan does not always match the statement sent to the foreign database. Here it would be better to enable gateway tracing and setting the trace level to ON. This will log the statements sent to the foreign database and you can compare what statement was sent with the statement you've tried to execute.

  • How to display All the rows in a Table

    Hi All,
    Our requirement is, we need to display all the records of an VO in a table. We should not have navigation bar with previous and next. Runtime only will come to know how many records the VO has. Is it possible to achieve our requirement using setNumberOfRowsDisplayed() method in OATableBean ?

    Do u want to do it declaratively or programmatically.
    Declaratively You can set no of rows property of table bean. If u want to set it programmatically then u can do it as discussed in the thread..
    Regards,
    Ram

  • Scroll all the rows in a table except the first row

    I have an HTML table
    for eg...
    <html>
    <div style="height:100px;overflow:auto">
    <table>
    <tr><td>xyz</td></tr> ///this row should not scroll
    <tr><td>123</td></tr> ///the rows repeated 100 times to allow scrolling
    </table>
    </div>
    </html>
    it gives me a nice table with a vertical scroll bar. What I want is my first row should not scroll. The scroll bar should be applicable from rows 2-100. I am not able to use this <div> tag exclusively to <tr>. Any inputs as to how this can be achieved.
    Raghav

    The whole problem is I lose the table alignment. if I have a table like
    <table>
    <tr><td>heading1</td><td>heading2</td><td>heading3</td></tr>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    //so on
    </table>
    all my rows from 2-99 are aligned properly under the first row.
    If I have a <div > tag or a new table for row "2-99"..the alignment is gone. "value1", value2 and value3 dont fall exactly under "heading1" "heading2" and heading3 respectively. I hope I made my point.
    <table>
    <tr><td>heading1</td><td>heading2</td><td>heading3</td></tr>
    <tr><td>
    <div style="height:100px; overflow:auto">
    <table>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    //so on
    </table>
    </div>
    </td></tr>
    </table>
    Raghav

  • How to make all the rows of a table editable

    I have a table in a view, with visibileRowCount property as 5. The internal table which is bound to the context has 2 rows.
    I want to make all the 5 rows of this table as editable. As of now, as there are just 2 rows in the internal table, only the first 2 rows of the table in the view are editable.
    My idea is to avoid the use of a 'Add row' button for this table. Is it possible to do this?
    Points will be rewarded. thanks.

    hi john....
                just insert 3 more empty records into your internal table... so it becomes editable.
    ---regards,
       alexb justin

  • Create a counter for the rows in a table using script editor?

    Hi ,
    I want to add afield in a particular table  with first field is its serial number . How to use scripting editor to fill the serial number ?
    How to create a counter ?
    Edited by: Rajan.Dexter9 on Jan 30, 2012 9:40 PM

    Hello Rajan,
    Create a field in the table and name it as 'SERIAL'.  Create a variable called 'count' with default value as 0.  Now in script editor, for javascript language and calculate event, write the following script.
    var fields = xfa.layout.pageContent(xfa.layout.page(this)-1, "field", 0);
    for (var i=0; i <= fields.length-1; i++)
         if (fields.item(i).name == "SERIAL")
              count.value = count.value + 1;
                     this.rawValue = count.value;     

  • How to update all the rows of table using stored procedures

    Hi,
    I want to update all the rows of a table of a specific column
    sp_a  male
    sp_b female
    sp_c  male
    sp_d female
    in above table 
    gender of all the columns has to be interchanged.

    Sir table is like this detail(name varchar(10),gender varchar(10))
    Where Details  are like this 
    Name  Gender
    sp_a 
    male
    sp_b
    female
    sp_c 
    male
    sp_d
    female
    I want to create a stored procedure which automtically updates gender from male to female and female to male
    for all the rows . i.e., all the rows are updated for column gender by just running a stored procedure.
    So after execution of stored proc the above table looks
    Name  Gender
    sp_a 
    female
    sp_b
    male
    sp_c 
    female
    sp_d
    male

  • Get all the rows of the table

    Hi,
         In my example I want to get all the rows of the table. The table has 20 rows. The visibleRowCount is set to 7 and firstVisibleRow is set to 3.
         I have created the table as
         var oTable = new sap.ui.table.Table({
               id: "oTable",
               title: "My Table",
               visibleRowCount: 7,
               firstVisibleRow: 3,
               selectionMode: sap.ui.table.SelectionMode.Single
         I tried to get the rows of the table using the below code
         var table = sap.ui.getCore().byId("oTable");
         var rows = table.getRows();     //     Returns only 7 rows     
        How to get all the rows of the table when the table is populated with a odata service  ?       

    Hi Vishal,
    The table only put in the html file the rows that you define in visiblerowcount (rows control). The method getRows, get this controls, and you only have 7. The table control render automacatically the data in thats rows when you scroll on it.
    If that you want is to retrieve the data of the rows, you need catch it from the model:
    oTable.getModel().getData();
    Regards,

  • How to list all the rows from the table VBAK

    Friends ,
    How to list all the rows from the table VBAK.select query and the output list is appreciated.

    Hi,
    IF you want to select all the rows for VBAK-
    Write-
    Data:itab type table of VBAK,
           wa like line of itab.
    SELECT * FROM VBAK into table itab.
    Itab is the internal table with type VBAK.
    Loop at itab into wa.
    Write: wa-field1,
    endloop.

  • Unselect all the rows when display my table the first time

    Hi all,
    When I execute my webdynpro the first time my table is displayed with the first row selected, but this is false, this line is not selected.
    If i execute the method get_selected_elements don't return anything in the table, but if i do a Click in this row then works fine.
    I tried to unselect all the rows when i display the table the first time in the method WDDOINIT doing the following;
    DATA lo_nd_my_table TYPE REF TO if_wd_context_node.
      DATA: lt_elements TYPE wdr_context_element_set,
                 lo_element TYPE REF TO if_wd_context_element,
                 lo_node TYPE REF TO if_wd_context_node.
      lo_nd_my_table = wd_context->get_child_node( name = wd_this->wdctx_my_table ).
      lt_elements = lo_nd_my_table->get_elements( ).
      LOOP AT lt_elements INTO lo_element.
        lo_element->set_selected( SPACE ).
      ENDLOOP.
    But, doesn't work...
    How can i do it?
    Thanks in advance.

    hi,Husalban RM     .
    You don't need to DE-SELECT each element of the context node.
    You can try the following:
    lo_node->set_lead_selection_index( -1 ).
    "lo_node is the context node which is bound to your table.
    Hope it can help you a little.
    Best wishes.

  • How to select all the rows of table control in BDC

    Hi All,
    While I am doing BDC for Transaction Code MC88, After the first screen I will get another screen with tabble control, Here I need to select all the rows of table control, I am assignng the 'X' to the first field of Table Control which is the indicator for selection.
    Here I am getting message called Indicator field is not in program and screen.
    While doing Recording I am not able to record the indicator, Please any one let me know how to record the Entire table control selection.
    Thanks in advance..

    Sorry about that lakshmi. Here is my code.
        PERFORM dynpro USING : 'X'   'SAPMMCP6'          '0105',
                               ' '   'RMCP2-MATNR'       t_matnr,
                               ' '   'RMCP2-WERKS'       t_werks,
                               ' '   'BDC_OKCODE'        '=AKTV'.
        PERFORM dynpro USING : 'X'   'SAPLMCPA'          '0707',
                               ' '   'BDC_OKCODE'        '=MRKE'.
        PERFORM dynpro USING : 'X'   'SAPLMCPA'          '0707',
                               ' '   'BDC_OKCODE'        '=GRAO

  • Display all the rows in the table with Varray

    I created two Varrays
    CREATE TYPE phone_varray AS VARRAY(3) OF NUMBER(10);
    CREATE TYPE email_varray AS VARRAY(3) OF varchar2(30);
    CREATE TABLE ee
    (id number(2),
    phone phone_varray);
    now i inserted some rows into ee table and displayed it as:
    SELECT e1.id,e2.COLUMN_VALUE"PHONE NO" FROM ee e1,TABLE(e1.phone) e2;
    ID PHONE NO
    1 1111111111
    1 2222222222
    1 3333333333
    1 1111111111
    1 2222222222
    1 4444444444
    4 1111
    4 2222
    4 33334
    5 1111
    5 2222
    5 33334
    Then i altered the table with email_varray
    desc ee;
    Name Null? Type
    ID NUMBER(2)
    PHONE PHONE_VARRAY
    EMAIL EMAIL_VARRAY
    I updated some rows:
    update ee e1 set email=email_varray('aasda') where id=4;
    and when i try to display the table data by:
    SELECT id,e2.*,e3.* from ee e1,TABLE(e1.phone) e2,TABLE(e1.email) e3;
    it only displays the rows that contain all the details like
    ID COLUMN_VALUE COLUMN_VALUE
    4 1111 aasda
    4 2222 aasda
    4 33334 aasda
    and not all the rows that are in the table which have id and phone and email as NULL
    need help to display all the rows in the table.

    will this work for you ?
    SELECT e1.id,e2.COLUMN_VALUE as PHONE_NO, null as email FROM ee e1,TABLE(e1.phone) e2
    union
    SELECT e1.id,null,e3.column_value as email from ee e1, TABLE(e1.email) e3;

  • Is there a way to BULK COLLECT with FOR UPDATE and not lock ALL the rows?

    Currently, we fetch a cursor on a few million rows using BULK COLLECT.
    In a FORALL loop, we update the rows.
    What is happening now, is that we run this procedure at the same time, and there is another session running a MERGE statement on the same table, and a DEADLOCK is created between them.
    I'd like to add to the cursor the FOR UPDATE clause, but from what i've read,
    it seems that this will cause ALL the rows in the cursor to become locked.
    This is a problem, as the other session is running MERGE statements on the table every few seconds, and I don't want it to fail with ORA-0054 (resource busy).
    What I would like to know is if there is a way, that only the rows in the
    current bulk will be locked, and all the other rows will be free for updates.
    To reproduce this problem:
    1. Create test table:
    create table TEST_TAB
    ID1 VARCHAR2(20),
    ID2 VARCHAR2(30),
    LAST_MODIFIED DATE
    2. Add rows to test table:
    insert into TEST_TAB (ID1, ID2, LAST_MODIFIED)
    values ('416208000770698', '336015000385349', to_date('15-11-2009 07:14:56', 'dd-mm-yyyy hh24:mi:ss'));
    insert into TEST_TAB (ID1, ID2, LAST_MODIFIED)
    values ('208104922058401', '336015000385349', to_date('15-11-2009 07:11:15', 'dd-mm-yyyy hh24:mi:ss'));
    insert into TEST_TAB (ID1, ID2, LAST_MODIFIED)
    values ('208104000385349', '336015000385349', to_date('15-11-2009 07:15:13', 'dd-mm-yyyy hh24:mi:ss'));
    3. Create test procedure:
    CREATE OR REPLACE PROCEDURE TEST_PROC IS
    TYPE id1_typ is table of TEST_TAB.ID1%TYPE;
    TYPE id2_typ is table of TEST_TAB.ID2%TYPE;
    id1_arr id1_typ;
    id2_arr id2_typ;
    CURSOR My_Crs IS
    SELECT ID1, ID2
    FROM TEST_TAB
    WHERE ID2 = '336015000385349'
    FOR UPDATE;
    BEGIN
    OPEN My_Crs;
    LOOP
    FETCH My_Crs bulk collect
    INTO id1_arr, id2_arr LIMIT 1;
    Forall i in 1 .. id1_arr.COUNT
    UPDATE TEST_TAB
    SET LAST_MODIFIED = SYSDATE
    where ID2 = id2_arr(i)
    and ID1 = id1_arr(i);
    dbms_lock.sleep(15);
    EXIT WHEN My_Crs%NOTFOUND;
    END LOOP;
    CLOSE My_Crs;
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20000,
    'Test Update ' || SQLCODE || ' ' || SQLERRM);
    END TEST_PROC;
    4. Create another procedure to check if table rows are locked:
    create or replace procedure check_record_locked(p_id in TEST_TAB.ID1%type) is
    cursor c is
    select 'dummy'
    from TEST_TAB
    WHERE ID2 = '336015000385349'
    and ID1 = p_id
    for update nowait;
    e_resource_busy exception;
    pragma exception_init(e_resource_busy, -54);
    begin
    open c;
    close c;
    dbms_output.put_line('Record ' || to_char(p_id) || ' is not locked.');
    rollback;
    exception
    when e_resource_busy then
    dbms_output.put_line('Record ' || to_char(p_id) || ' is locked.');
    end check_record_locked;
    5. in one session, run the procedure TEST_PROC.
    6. While it's running, in another session, run this block:
    begin
    check_record_locked('208104922058401');
    check_record_locked('416208000770698');
    check_record_locked('208104000385349');
    end;
    7. you will see that all records are identified as locked.
    Is there a way that only 1 row will be locked, and the other 2 will be unlocked?
    Thanks,
    Yoni.

    I don't have database access on weekends (look at it as a template)
    suppose you
    create table help_iot
    (bucket number,
    id1    varchar2(20),
    constraint help_iot_pk primary key (bucket,id1)
    organization index;not very sure about the create table syntax above.
    declare
      maximal_bucket number := 10000; -- will update few hundred rows at a time if you must update few million rows
      the_sysdate date := sysdate;
    begin
      truncate table help_iot;
      insert into help_iot
      select ntile(maximal_bucket) over (order by id1) bucket,id1
        from test_tab
       where id2 = '336015000385349';
      for i in 1 .. maximal_bucket
      loop
        select id1,id2,last_modified
          from test_tab
         where id2 = '336015000385349'
           and id1 in (select id1
                         from help_iot
                        where bucket = i
           for update of last_modified;
        update test_tab
           set last_modified = the_sysdate
         where id2 = '336015000385349'
           and id1 in (select id1
                         from help_iot
                        where bucket = i
        commit;
        dbms_lock.sleep(15);
      end loop;
    end;Regards
    Etbin
    introduced the_sysdate if last_modified must be the same for all updated rows
    Edited by: Etbin on 29.11.2009 16:48

  • How to show all the rows of a report in one page

    My report has 30 rows, by default it just show 15 rows. I want to show all the rows just in one page, without cliking link or arrow to see the left.
    In the Layout and Pagination:
    Report Template: template: 15. Standard Report (PPR)
    Pagination Scheme: Row Ranges X to Y (no pagination)
    Display Position: Bottom - Right
    Number of Rows: 1000
    Number of Rows (item) 1000
    Maximum Row Count: 1000
    How to fix it?
    Thanks.
    Jen

    Ok, I think I got it. I needed to blank out Number of Rows(item), Maximum row count and only populate Number of Rows. I was sure I did that before and it didnt work.
    Do you think that the Sessions in Apex can cause unexpected results? I have found that when I make changes I have to log all the way out of Apex, close my browser and reopen everything to ensure that my change took. Does anyone else have this issue? I can move this into a different thread if need be.
    Thx!

Maybe you are looking for

  • Updation error while using a foreign data source

    Hi All, I am trying to connect to SQL server 2000, from my BC4J driven swing application. i am using Oracle containers for Java (Development Suite) Going by the steps detailed in "SQL Server Walkthrough" on OTN, i have tested with two drivers: 1) Mic

  • Error while executing DI job

    Hi, we executed a Job and execution went fine for many Workflows and it got aborted in a dataflow with a strange error. Please Find Below the error.   @SRV-210112, ERROR, 0, 0.000, 8671.266, 0.000, 0, SRV-210112: |Dataflow sample_SF_DF: Data flow fai

  • Mac Mini 2012 (new) - displayport daisy chaining.

    Does anybody know whether the TB controller on the 2012 (new) Mac Mini supports DisplayPort v1.2 daisy chaining? I am aware of the limitations of the current Apple TB display, but am wondering if a workaround would be to use display v1.2 panels. My g

  • 3.12 post element text appearing on new line

    I have an icon and some javaScript behind it to clear the content of the item, which on moving to 3.12 is moved onto the next line: http://apex.oracle.com/pls/otn/f?p=41395:10 Is there a simple way of avoiding this please so that it all appears on th

  • How to lock a folder using admin password??

    hello, i want to lock a folder with admin user name and password, and, i dont want to use Utilities->Disk Utility then Select File->New...->Blank Disk Image. Can we lock a folder without creating an image??? plz help!!! i have mountain lion, 27inch i