Combining/ merging rows in PowerPivot

Hi,
Currently what happens is when I create a Pivot Table based on the first table I get count for ABC10 as 2, but ideally it should be 1. I want to combine Sub Bill Type if BILL NO and BILL TYPE is same. Ideally second row shouldn't be considered into calculation,
but should include SUB BILL TYPE.
Is there any formula to achieve this?
I am not a query expert, so no idea if it's possible using query. Recently I am using this query.
SELECT AL1.BILL_NO as "Bill No", AL1.REF_NO as "Ref No", AL1.REF_MOD as "Reference Module",
AL1.STATUS "Bill Status", AL1.PAYER_NAME as "Payer Name", AL1.BILLING_DT as "Billing Date",
AL1.DUE_DT as "Due Date", AL1.ID_TYPE as "ID Type", AL1.ID_NO as "ID No",
AL1.REMARKS as "Remarks", AL4.FEELIST_ID as "FeeList ID",
AL4.FEE_ID as "Fee ID", AL4.QUANTITY as "Quantity", AL4.GST_AMT as "GST Amount",
AL4.GST_ABSORBED as "GST Absorbed", AL4.SUBTOTAL as "Sub Total", AL3.BILL_TYPE as "Bill Type",
AL3.SUBBILL_TYPE as "Sub Bill Type", AL3.AMOUNT as "Amount", AL2.PAY_ID as "Pay ID",
AL2.PAYMENT_MODE as "Payment Mode", AL2.PAY_STATUS "Pay Status",
AL2.CHQ_ID as "Cheque ID", AL2.RECEIPT_NO as "Receipt No", AL2.COLLECTION_CTR as "Collection Centre",
AL2.PAYMENT_DT as "Payment Date", AL2.PAID_AMOUNT as "Paid Amount",
AL2.TRANS_DT as "Transaction Date", AL5.WORKPLACE_NAME  as "Workplace Name"
FROM BIL_BILL AL1, BIL_PAY AL2, BIL_BILLING_FEE AL3, BIL_FEELIST AL4, LIC_WP_DET AL5
WHERE (AL1.BILL_NO = AL4.BILL_NO (+) AND  AL1.REF_NO = AL5.WORKPLACE_NO (+) AND
AL1.BILL_NO=AL2.BILL_NO AND AL4.FEE_ID=AL3.FEE_ID)  AND (AL2.PAY_STATUS='PD' AND
AL1.DELETE_IND='F' AND AL2.DELETE_IND='F')
Thanks,
SS

Hi ,
  Please check out the below link for the solution in Power Pivot
Group Multiple Rows to Single Delimited Row in PowerPivot
For achieving this in SQL , check the below link. This will work for SQL server. But your query looks like Oracle one.
TSQL – Concatenate Rows using FOR XML PATH()
Best Regards Sorna

Similar Messages

  • Importstring with xml merging row data

    I have a simple XML import I'm trying to do, rather than manually parsing the data. There's a problem though. The following XML generates 3 rows in the datawindow instead of 4. I'm using a default template.
    <?xml version="1.0"?><dw_tqxml>
    <dw_tqxml_row><dosetime>AM</dosetime><qty>1</qty></dw_tqxml_row>
    <dw_tqxml_row><dosetime>8pm</dosetime><qty>1.25</qty></dw_tqxml_row>
    <dw_tqxml_row><dosetime>NOON</dosetime></dw_tqxml_row>
    <dw_tqxml_row><qty>3.00</qty></dw_tqxml_row>
    </dw_tqxml>
    The first and second rows come out fine, the third row is a combination of the two last rows.
    Here's the result data
    "AM", "1"
    "8pm", "1.25"
    "NOON", "3.00"
    dw sql is:
    select space(10) as dosetime, space(10) as qty from dummy
    It's my understanding that missing data should use the default values in the datawindow.
    PB 12.5 Build 5583
    Anyone have any ideas on why it's merging rows? This is the first time I've used XML import, don't really have a clue what I'm missing.

    I have limited experience with XML import. What I have just found is:
    Column tag names are ignored during import.
    The import "finds" the data between each detail item.
    Appears to completely ignore the surrounding "row" tags.
    Your XML file needs empty detail tags when there is no data. No PowerBuiilder import function will assign default values. Only InsertRow() function does that.
    XML imports/exports works really well with nested or composite datawindows. There are templates generated that you can use.  Not sure how templates work.

  • How to merge rows with similar values in alv grid display in webdynpro

    Hi experts,
                   i want to know about how to merge rows with similar values in alv grid display of webdynpro.grouping rows is possible in table display in webdynpro but i am not able to do row grouping in the alv grid display in webdynpro.
    kindly suggest.
    thanks ,
    Anita.

    Hi Anita,
    did you find a solution for this? I have opened a Thread, if you know the answer maybe you could help me out:
    Is there an ALV function similar to the TABLE Row grouping?
    Thanx in advanced!!!
    Kind Regards,
    Gerardo J

  • Merge row in ALV

    hello everyone, im having a problem woth my ALV, how can i merge rows in ALV,
    example i want to merge row 3 and row 4?
    Another 1 how can I format a certain row in ALV?
    example row 5, I want the displayed value be centered, or right aligned, or left aligned...
    thank you very much

    Christopher,
    I am not sure what is the functionality you are trying to achieve by merging rows. If you SORT the rows, there should be a option (Iam not sure whether it is in the field catalog or the layout most probably in the layout), where the rows with the same for specific columns will automatically get merged. However, it does not make sense if the entire row is duplicated. You probably can delete the adjacent duplicates by sorting the table even before displaying the data.
    I am not sure the formatting that you are asking, but you can trying passing different values to LVC_T_STYLE type table which has to be a part of you data internal table. So, for a specific row, you append the column names and the specific style that you want for individual columns.
    Regards,
    Ravi
    Note : Please reward points if this helps you.

  • Excel 2007 Merge Rows

    How can I merge rows together to go from this:
    1
    2
    3
    A
    F
    A
    G
    A
    D
    H
    B
    I
    B
    J
    C
    K
    C
    L
    C
    M
    C
    E
    N
    To this:
    1
    2
    3
    A
    D
    F, G, H
    B
    I, J, K
    C
    E
    L, M, N

    Try VBA  code:
    Sub Test()
    Dim d1 As Object, d2 As Object, d3 As Object, i%, arr
    Set d1 = CreateObject("scripting.dictionary")
    Set d2 = CreateObject("scripting.dictionary")
    Set d3 = CreateObject("scripting.dictionary")
    arr = Range("A1").CurrentRegion
    For i = 2 To UBound(arr)
    For j = 2 To Application.CountA(ActiveSheet.Range("1:1"))
    d1(arr(i, 1)) = ""
    d2(arr(1, j)) = ""
    d3(arr(i, 1) & arr(1, j)) = d3(arr(i, 1) & arr(1, j)) & arr(i, j)
    Next
    Next
    Range("B16").Resize(1, d2.Count) = d2.keys
    Range("A17").Resize(d1.Count, 1) = Application.Transpose(d1.keys)
    For i = 17 To d1.Count + 16
    For y = 2 To d2.Count + 1
    If d3.exists(Cells(i, 1) & Cells(16, y)) Then
    Cells(i, y) = d3(Cells(i, 1) & Cells(16, y))
    End If
    Next
    Next
    End Sub
    Wind Zhang
    TechNet Community Support

  • Combining 2 rows in a table

    Hi,
    How do I combine 2 rows in a table to get a single row.
    Here is the Query and Output
    Query:
    SELECT ALL T.TEAM_ID, T.TEAM_NAME, T.TEAM_LEADER_NAME, TD.AUG_EMP_TRNED, TD.AUG_TOTAL_EMP,
    TD.SEP_EMP_TRNED, TD.SEP_TOTAL_EMP FROM TEAM T, TRNG_DETAILS TD WHERE T.TEAM_ID = TD.TEAM_ID
    AND TD.TRNG_FREQUENCY ='Monthly' AND TD.TEAM_ID = 3
    Result:
    Row     TEAM_ID     TEAM_NAME     TEAM_LEADER_NAME     AUG_EMP_TRNED     AUG_TOTAL_EMP     SEP_EMP_TRNED     SEP_TOTAL_EMP
    1     3     ABCv     gg     (null)     (null)     8     8
    2     3     ABCv     gg     12     12     (null)     (null)
    I want to get this result in one row with all values ........
    Thanks in advance

    Assuming your goal is to pick the non-NULL value...
    SELECT team_id, team_name, team_leader_name, max(aug_emp_trned), max(aug_total_emp), ...
      FROM (<<your query>>)
    GROUP BY team_id, team_name, team_leader_nameIf by combining the rows you ean something else (i.e. taking a SUM), you would change the MAX call above to a SUM
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Macro/VBA script to merge rows with same values in another column

    Hi.
    I'm developing a dance competition application, using Excel 2010, and have so far managed to put judges' marked scores into a worksheet through a userform.
    Now I would like to make the worksheet more presentable as a scoreboard, as you would manually, but via VBA scripts.
    Exhibit Numbers (Column G) are unique identifiers (per competition) for contestants and each contestant is typically judged by three judges.  The scores in three separate categories from one judge would spread in one row so each contestant would have three
    rows.
    I would like to merge rows of columns where the totals from the judges go (Columns P to U) for each contestant.
    I've considered using some kind of loop but I don't have enough experience in vba scripting, it gets overcomplicated. Could someone please help?
    Many thanks.
    Maki Koyama (Canberra, AUS)

    Hi,
    You cannot add a static "Y" inside a when looping over "i". You need to ensure that "Y" changes along with X. Try the modified code below.
    List elements = new ArrayList();
    for (int i=0; i<XXX; i++) {
    IZZZ.IVisibilityElement el = wdContext.createVisibilityElement();
    el.setVisAttr(i); // Change Y to i
    elements.add(el);
    wdContext.nodeVisibility().bind(elements);
    That should give you an idea of what is erroneous in the code.
    Thanks.
    HTH.
    p256960

  • How to combine many rows into one row

    Hi all,
    I have a question regarding to how to combine many rows into one row?
    My result set is like that:
    ITEM_NO NAME1
    11 abc
    11 cde
    11 fg
    Want to combine them into
    ITEM_NO NAME1
    11 abc;cde;fg
    would anybody can tell me how to do that? Thanks
    Ray

    You can check this --
    satyaki>
    satyaki>
    satyaki>create table t
      2  as
      3      select 11 ITEM_NO, 'abc' NAME1 from dual
      4      union all
      5      select 11 ITEM_NO, 'cde' NAME1 from dual
      6      union all
      7      select 11 ITEM_NO, 'fg' NAME1 from dual;
    Table created.
    satyaki>
    satyaki>
    satyaki>
    satyaki>set lin 10
    satyaki>
    satyaki>desc t;
    Name              Null?    Type
    ITEM_NO                    NUMBER
    NAME1                      VARCHAR2(3)
    satyaki>
    satyaki>
    satyaki>set lin 1000
    satyaki>
    satyaki>
    satyaki>
    satyaki>SELECT ITEM_NO,
      2         LTRIM(MAX(SYS_CONNECT_BY_PATH(NAME1,';'))
      3         KEEP (DENSE_RANK LAST ORDER BY curr),';') AS NAME1_DET
      4  FROM   (SELECT ITEM_NO,
      5                 NAME1,
      6                 ROW_NUMBER() OVER (PARTITION BY ITEM_NO ORDER BY NAME1) AS curr,
      7                 ROW_NUMBER() OVER (PARTITION BY ITEM_NO ORDER BY NAME1) -1 AS prev
      8          FROM   t)
      9  GROUP BY ITEM_NO
    10  CONNECT BY prev = PRIOR curr AND ITEM_NO = PRIOR ITEM_NO
    11  START WITH curr = 1;
       ITEM_NO  NAME1_DET
            11  abc;cde;fgRegards.
    Satyaki De.

  • Merging rows into one row but into SEPARATE Columns

    Hello Gurus,
    I have searched alot on OTN and many other places, but no where I could get the solution of how can we merge rows into one row but separate column. For example
    Consider the below scenario
    "DEPARTMENT", "EMP","NAME","SUBJECT"
    "Electronics","1","Sam","LIC"
    "Electronics","2","Pam","VLSI"
    "Electronics","3","Tom","C"
    "Mech","1","Abu","Thermo"
    "Mech","4","Lina","Machines"Now, I need the output like
    Based on Department as Group By Clause
    "DEPARTMENT", "EMP1","NAME1","SUBJECT1","EMP2","NAME2","SUBJECT2","EMP3","NAME3","SUBJECT3"
    "Electronics","1","Sam","LIC","2","Pam","VLSI","3","Tom","C"
    "Mech","1","Abu","Thermo","4","Lina","Machines"
    The row data to be loaded into separate columns. Name of the column is not an issue... can be anythingIn all the forums which I went through I could find them loading into a single column, but not into respective separate columns.
    Any help would be much appreciated.
    Thanks

    848265 wrote:
    Frank,
    I saw your name nearly n number of times, as I went through many forums today... And the link which you have just posted, I went through it today afternoon.
    Could you please explain this bit taken from your dynamic pivot post.
    SELECT     DISTINCT
         ',     COUNT (CASE WHEN job = '''
    ||     job
    ||     ''' '     AS txt1
    ,     'THEN 1 END)     AS '
    ||     job
    ||     '_CNT'     AS txt2
    FROM     scott.emp
    ORDER BY     txt1;Many Thanks.You only need that when you need column aliases based on the actual data (and you explicitly said you don't need that) or when can't put an upper bound on the number of columns to be displayed. If that doesn't apply to this problem, then don't use any kind of dynamic SQL (like the code above); it makes the job much more difficult, less efficient and less robust.
    Here's what the code above is doing.
    If you were hard-coding a query that showed the number of people in each job, and you knew that the possible jobs were 'ANALYST', 'CLERK' and 'MANAGER', then you might hard-code a query like this:
    SELECT    deptno
    ,       COUNT (CASE WHEN job = 'ANALYST'  THEN 1 END)     AS analyst
    ,       COUNT (CASE WHEN job = 'CLERK'    THEN 1 END)     AS clerk
    ,       COUNT (CASE WHEN job = 'MANAGER'  THEN 1 END)     AS manager
    FROM       scott.emp
    GROUP BY  deptno
    ;If the jobs had different names, or if there were not 3 different jobs, then you would have to change the lines in the SELECT clause that start with ", COUNT ( CASE ...".
    The code you posted is from an example of dynamic SQL, where you first run a Preliminary Query . (What you posted above is, in fact, the complete preliminary query.) The output of that preliminary query is exactly the variable part of the real query, such as:
    ,       COUNT (CASE WHEN job = 'ANALYST'  THEN 1 END)     AS analyst
    ,       COUNT (CASE WHEN job = 'CLERK'    THEN 1 END)     AS clerk
    ,       COUNT (CASE WHEN job = 'MANAGER'  THEN 1 END)     AS managerYou then use this output as part of your main query. In other words, you can write something today that will generate exacrly as many columns as you need next year, with names from the data as it is next year. How? because you're not writing the full query today. The variable part will be written by the preliminary query when it runs next year.

  • Combine multiple rows in single row

    I am new to SQL server and i am trying to combine multiple row in single row but i am not able to do it.Can anyone help me out?
    Input :
    Id |RED |BUY |BSW
    1328 NULL NULL 0.05
    1328 NULL 0.06 NULL
    1328 0.01 NULL NULL
    1328 0.05 NULL NULL
    1329 NULL NULL 0.05
    1329 NULL 0.05 NULL
    1329 0.05 NULL NULL
    Output
    Id |RED |BUY |BSW
    1328 0.01 0.06 0.05
    1328 0.05 NULL NULL
    1329 0.05 0.05 0.05

    Actually I am consolidating above result into text file and sending it to external system.Main aim is to remove NULL values and arrange the data as expected output.
    Also expected output can be
    Id         |RED   
    |BUY    |BSW
    1328        0.05   
    0.06    0.05
    1328        0.01   
    NULL    NULL
    Or
    Id         |RED   
    |BUY    |BSW
    1328        0.01   
    0.06    0.05
    1328        0.05   
    NULL    NULL
    for Id= 1328.

  • How to combine many rows into 1 rows in 1 column?

    Hi all,
    I have a question regarding to how to combine many rows into one row?
    My result set is like that:
    ITEM_NO NAME1
    11 abc
    11 cde
    11 fg
    Want to combine them into
    ITEM_NO NAME1
    11 abc;cde;fg
    would anybody can tell me how to do that? Thanks
    Ray

    Hi,
    select * from x2;
    INO NAME
    13 PQR
    11 ABC
    11 DEF
    12 JKL
    12 MNO
    11 GHI
    select p.ino as ITEMNO,
           substr(max(substr(sys_connect_by_path (p.name,';'),2)),1,60) as ITEMNAME
    from (select ino,name,
          row_number()over (partition by ino order by ino, name) rn
    from x2) p
    start with p.rn = 1
    connect by p.rn = prior p.rn + 1
    and prior p.ino = p.ino
    group by ino;
    OP
    ITEMNO ITEMNAME
    11 ABC;DEF;GHI
    12 JKL;MNO
    13 PQR cheers
    Nirmal

  • Combine fillable rows

    I'm trying to create a fillable form from an existing Excel document. In the Excel document, I left two rows of space for the end user's response. Now that it is in PDF, these rows for the response do not wrap the text. Is it possible to combine the rows/fields or wrap text?
    Thanks!

    thanks. is there something else that i need to do? even with multiline selected, it's still just skrinking the text instead of allowing for another line. does the formatting in excel have something to do with it?

  • How to combine/merge files in pages on ipad

    how do I merge or combine separate documents in pages on my ipad?

    Copy and paste. There is no file merge function in Pages for iOS.

  • Sql Query : Sum , all the possible combination of rows in a table

    SQL Server 2008 R2
    Sample Table structure
    create table TempTable
    ID int identity,
    value int
    insert into TempTable values(6)
    insert into TempTable values(7)
    insert into TempTable values(8)
    insert into TempTable values(9)
    insert into TempTable values(10)
    I actually want something like below,
    that It returns rows such that, it has the sum of all the remaining rows , as shown below.
    I will ignore the repeated rows.
    6+7
    6+8
    6+9
    6+10
    6+7+8
    6+7+9
    6+7+10
    6+8+9
    6+8+10
    6+9+10 
    6+7+8+9
    6+7+8+9+10

    This makes no sense. What about NULLs? What about duplicate values? You have rows, so you have many combinations. We know that this set totals to 39, so there is no subset totals to half of any odd number.  19.5
    in this case. 
    None of your examples are
    even close! 
     6+7 = 13
    the remaining rows 8+9+10 = 27, so you failed! 
    Want to try again?
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Combine 2 rows

    I have result of a query as :
    emp_id emp_name wife_1 wife_2 wife_3
    12   abc      xx
    12   abc          yy
    34  xyz         tt
    34  xyz           pp
    34   xyz                  uu
    I want to combine these reords so that the result should be like this :
    emp_id emp_name wife_1 wife_2 wife_3
    12 abc xx yy
    34 xyz tt uu pp
    This is what I explained easily. Now in my query i have used DECODE 3 times as
    DECODE (SEDT2.CDT_ROLE_CD, 'smart', spouse_table.wife, null) as wife_1,
    DECODE (SEDT2.CDT_ROLE_CD, 'ugly', spouse_table.wife, null) as wife_2,
    DECODE (SEDT2.CDT_ROLE_CD, 'MARSHUS_ROLE_SP', spouse_table.wife, null) as wife_3,
    When I removed these decode statements the result is as :
    emp_id emp_name
    12 abc
    34 xyz
    Why the decode statements giving me problem?
    Due to bussiness policy of my employeer, I can not post my actual query here.
    I know , without knowing query , to figure out the cause is diffcult, but still any help , clue in this scenario is appriciable.
    Thankx in advance

    SQL>
    SQL> drop table test_table
      2  /
    Table dropped.
    SQL>
    SQL> create table test_table(emp_id number, ename varchar2(32), wife varchar2(32))
      2  /
    Table created.
    SQL> INSERT into test_table values(12, 'abc', 'xx')
      2  /
    1 row created.
    SQL> INSERT into test_table values(12, 'abc', 'yy')
      2  /
    1 row created.
    SQL> INSERT into test_table values(34, 'xyz', 'tt')
      2  /
    1 row created.
    SQL> INSERT into test_table values(34, 'xyz', 'pp')
      2  /
    1 row created.
    SQL> INSERT into test_table values(34, 'xyz', 'uu')
      2  /
    1 row created.
    SQL>
    SQL>
    SQL> select emp_id
      2       , ename
      3       , max(decode(r, 1, wife, null)) wife_1
      4       , max(decode(r, 2, wife, null)) wife_2
      5       , max(decode(r, 3, wife, null)) wife_3
      6  from(select emp_id, ename, wife,row_number() over (partition by emp_id order by ename) r
      7  from test_table)
      8  group by emp_id, ename
      9  /
        EMP_ID ENAME                            WIFE_1                           WIFE_2                           WIFE_3                                                                                   
            12 abc                              xx                               yy                                                                                                                        
            34 xyz                              tt                               pp                               uu                                                                                       
    SQL>
    SQL> spool off

Maybe you are looking for

  • Photo Quality in iDVD

    I work with still photos only. Want a slideshow that maintains photo image quality. iMovie coverts to video file & degrades the quality. Changed to FotoMagico. Maintains photo quality in slideshow & offers transitions, KB effect & title slides. It ex

  • Why mac pro 2013 not supporting illustrator GPU rendering

    Here, all nvidia cards supporting this: http://helpx.adobe.com/illustrator/kb/gpu-performance-preview-improvements.html now I'm thinking, that buying the new mac pro 2013 maybe wasn't the best idea... Apple put in AMD GPu's, that is fine by me, but c

  • White background on output?

    Hi, guys! Sorry for the stupid question, but how do you change the output background from black to white? Thank you!

  • Can't open iunes!

    Windows said :"Tunes has encountered a problem and needs to close. We are sorry for the inconvenience." I have tried to uninstall , reinstall, use msconfig... for times but it still doesn't work. Help me please!

  • IPhoto Organize Library or Manually?

    I just got a Rebel XT and now I'm not sure what to do with my iPhoto library. I had been using a small 2 megapixel Canon PowerShot for years and would just import directly into iPhoto on my G5. Before version 6, the library was simply stored in neste