Trouble trying to replicate GROUP BY/DISTINCT and SUM in PowerPivot with DAX

I have the following records table (ignore the commas)
unqPath, Channel, PathLength, UnqPathLength
8726, direct, 2, 2
8726, direct, 2, NULL
8726, organic, 1, 1
28364, paid, 2, 2
28364, display, 2, NULL
287364, email, 4, 4
287364, email, 4, NULL
287364, direct, 4, NULL
287364, email, 4, NULL
Each record (unqPath) can have multiple channels. For each record I have Path length which is the number of channels associated with that record (this was achieved in SQL doing a count and partitioning it over record name). I have also created another column
called UnqPathLength where I list the PathLength for each record only once (on the row associated with the 1st channel)
In PowerPivot, I want to sum the PathLength of all records where a certain channel appears. So direct appears in 2 records which have Path Lengths 2 and 4 respectively so I'd like to have 6 for that.
I have tried everything from using summarise, distinct but the path length is almost always double counted when the same channel appears twice in the same record. Also tried using unqPathLength (figured this would help with the duplicate counting) but it
only works when the channel is on the same row and returns incorrect results.
Here are some of my efforts
# pathLengthChannel:=
SUMX(
SUMMARIZE(
'query',
'query'[unqPath],
'query'[channel],
'query'[pathLength],
"pathLengthChannel0",
SUM('query'[pathLength])
),[pathLengthChannel0]
)OR# pathLengthChannel:=SUMX(
    DISTINCT([unqPath]),
    SUM('query'[pathLength])
Any ideas would be greatly appreciated. Many thanks.

This should work assuming that whenever the unqPath and channel are the same that the pathLength is too:
=SUMX(
SUMMARIZE(
query,
query[unqPath],
query[Channel],
"Path",
MAX(query[PathLength])
[Path]

Similar Messages

  • I have been trying to update via App Store and every time only with apple software it starts to download and it will says it's calculating time remaining then an error message pops up saying " An error has occurred the request timed out. (102) "

    I have been trying to update via App Store and every time only with apple software it starts to download and it will says it's calculating time remaining then an error message pops up saying " An error has occurred the request timed out. (102)" I have tried everything , I've been told its my ISP but I have tried using differenet internet to attempt the updates. Like I said all other software updates fine its just apple software

    http://www.apple.com/support/mac/app-store/contact.html?form=account

  • I just tried the 'group tabs' function but when I close a window and open a new one, the last page I viewed opens every single time. I can't remove or ignore the group tabs function and it automatically opens with it. How can I stop this?

    Before I attempted using the 'groups tab' function for the first time, there was no icon (unlike currently). There is now the icon with for the function yet I am unable to remove it or its function.

    Try a clean reinstall and delete the Firefox program folder and desktop shortcut before (re)installing a fresh copy of the current Firefox release.
    Download a fresh Firefox copy and save the file to the desktop.
    *Firefox 23.0: http://www.mozilla.org/en-US/firefox/all.html
    Uninstall your current Firefox version, if possible, to cleanup the Windows registry and settings in security software.
    *Do NOT remove personal data when you uninstall your current Firefox version, because all profile folders will be removed and you lose personal data like bookmarks and passwords from profiles of other Firefox versions.
    Remove the Firefox program folder before installing that newly downloaded copy of the Firefox installer.
    *(32 bit Windows) "C:\Program Files\Mozilla Firefox\"
    *(64 bit Windows) "C:\Program Files (x86)\Mozilla Firefox\"
    *It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    *http://kb.mozillazine.org/Uninstalling_Firefox
    Your bookmarks and other personal data are stored in the Firefox profile folder and won't be affected by an uninstall and (re)install, but make sure that "remove personal data" is NOT selected when you uninstall Firefox.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    *http://kb.mozillazine.org/Profile_backup
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Clean_reinstall

  • Page group deletion failed, and now it posts with no links

    A page group needed to be deleted because the template it was based on is corrupted. Now the page group shows with no links at all. It can't be viewed, edited, NOTHING!. How can I get that page group truly deleted, even if it is manually, so that I can proceed to a clean import of a backed up page group before the template was messed up?
    The list of error messages from the delete procedure were:
    Error while deleting page. (WWC-44130)
    An unexpected error occurred: User-Defined Exception (WWC-44082)
    (WWC-00000)
    An unexpected error occurred in portlet instances: User-Defined Exception (WWW-44846)
    An unexpected error occurred: User-Defined Exception (WWC-43000)
    An unexpected error occurred: User-Defined Exception (WWC-43000)
    An unexpected error occurred: User-Defined Exception (WWC-43000)
    Please help me out...
    Jamileth

    This looks like Bug 2034579, which is an internal bug but basically documents the same thing. I've tried to reproduce this in 9.0.2.2 and it doesn't.
    Please raise a service request with Oracle Support who should be able to assist you with the correct course of action.
    Thanks.

  • Group by month, and also show months with no records

    hi - having a major mental block this morning, pretty sure this is an easy one so just need one of you expert types to point me in the right direction..
    Using the sample data below, I just need to generate a report to show userid, mon-yy, count of transactions. I need to show the full 12 months, so with a zero if there's no transactions.
    I'm not sure if this is the right approach but I'm using a subquery to generate the 12 months, as obvisouly they're not in the transaction data. The fact I have to to_char against the subquery kind of set alarm bells ringing though, I think there's a better solution but as I say, mental block.
    The query at the end was to show the subquery thing works, but for the life of me I can't think today how to extend this to include the userid and give me the desired result (bottom code block).
    Frustrating when this should be relatively simple!?!
    thanks in advance all :o)
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    create table trans (pkid number, userid number, transdate date);
    insert into trans values (1, 10, sysdate-300);
    insert into trans values (2, 10, sysdate-100);
    insert into trans values (3, 20, sysdate-100);
    insert into trans values (4, 20, sysdate-50);
    insert into trans values (5, 20, sysdate-20);
    commit;
    select * from trans;
          PKID     USERID TRANSDATE
             1         10 05-AUG-10
             2         10 21-FEB-11
             3         20 21-FEB-11
             4         20 12-APR-11
             5         20 12-MAY-11
    select sub.mon, count(t.transdate) from trans t,
    (select to_char(add_months(sysdate, -level),'MON-YY') as mon
    from dual
    connect by level <=12) sub
    where sub.mon = to_char(transdate(+),'MON-YY')
    group by sub.mon
    order by to_date(sub.mon,'MON-YY')
    MON    COUNT(T.TRANSDATE)
    JUN-10                  0
    JUL-10                  0
    AUG-10                  1
    SEP-10                  0
    OCT-10                  0
    NOV-10                  0
    DEC-10                  0
    JAN-11                  0
    FEB-11                  2
    MAR-11                  0
    APR-11                  1
    MAY-11                  1
    12 rows selected.Desired:
    10  JUN-10  0
    10  JUL-10  0
    10  AUG-10  1
    ...and so on until...
    10  MAY-11  0
    20  JUN-10  0
    20  JUL-10  0
    20  AUG-10  0
    ...and so on until...
    20  FEB-11  1
    20  MAR-11  0
    20  APR-11  1
    20  MAY-11  1

    Hi,
    That's what a Partitioned Outer Join does:
    select        sub.mon
    ,        count (t.transdate)
    from        (
              select      to_char ( add_months (sysdate, -level)
                        , 'MON-YY'
                        ) as mon
              from      dual
              connect by      level      <= 12
           ) sub
    left outer join trans     t     PARTITION BY (t.userid)
                        ON      sub.mon = to_char (transdate,'MON-YY')
    group by  t.userid
    ,       sub.mon
    order by  t.userid
    ,       to_date (sub.mon,'MON-YY')
    ;A regular outer join guarantees that you'll get each row from the driving table displayed at least once. But you want each row from sub displayed n times, where n is the number of distinct userids found in t. "PARTITION BY t.userid" means "treat each distinct value of userid as a separate table", and the results will all be UNIONed together.
    Partitioned outer joins were new in Oracle 10. Before that, you had to form a result set of the distinct values of userid, then cross-join that with the distinct months from sub, and finally outer-join that to the real data.

  • Trying to download photoshop cs4 trial and keeps coming up with error message

    trying to download cs4 keep getting error message

    The error message we receive when we try to download the trial is:
    Akamai Download Manager
    File Name                   Progress         Size        Status
    URL                                                        Save As
    ADBEPHSPCS4_L...     0%                              Error
    http://trials.adobe.com/Appplications/P...    C:\Users\Brandon\Docu..
    ADBEPHSPCS4_L...     0%                              Error
    http://trials.adobe.com/Applications/P...      C:\Users\Brandon\Docu..
    Resume                Details
    Cancel
    Exit
    Now, we've talked to 6 representatives and got your message and all I want
    is to get instructions and help downloading a free 30-day trial.

  • Distinct and Sum

    Hi,
    I am trying to build an oracle query that would simplify my life.
    I have table labtrans which contains fields regularhrs ( float ) , premiumhrs (float ) , craft ( varchar ) and wonum ( varchar ) . Craft is the type of labor and wonum is the key.
    The fact is that there are a lot of possible craft for a single wonum. I would like to sum all premiumhrs and regularhrs for EACH craft. Which means that if MANUSE come 10 times, I only want ONE line of MANUSE with the sum of all his premiumhrs and the sum of regularhrs.
    Is it even possible ??
    my current query is : select L.transdate, L.regularhrs, L.premiumpayhours, L.payrate, L.craft, L.linecost, L.gldebitacctdep from LABTRANS L where L.refwo = '$WONUM'
    Thanks

    I would like to sum all premiumhrs and regularhrs for EACH craft. Which means that if MANUSE come 10 times, I only want ONE line of MANUSE with the sum of all his premiumhrs and the sum of regularhrs.
    If I understand correctly if there are 10 records for MANUSE_1 and within the 10 MANUSE_1 records there are 3 records for CRAFT1, three for CRAFT2, and 4 for CRAFT3 you want the output to be:
    MANUSE_1
    CRAFT1 | 40 regular hours | 10 premium hours
    CRAFT2 | 5 regular hours | 0 premium hours
    CRAFT3 | 19 regular hours | 4 premium hours
    Is this correct?
    If you want script out the some records from your table and email them to me and I can give you an example.
    Edited by: jmurch on Sep 23, 2010 9:57 AM

  • Difference between Group A/c and Chart of Account with serval Company Code

    Hi Friends,
    Please explain the term chart of account with serval company code and also group a/c.
    Thanks and regards,
    Dev

    Hi Mahendra
    The Chart of Accounts is a list/directory of the G/L acounts maintained in the company. This COA can be used by one or many company codes.
    For e.g Co code A located in Delhi and Co code B In Mumbai may use the same COA for reporting as well as consolidation purpose.
    Group COA is maintained when there are more than one COA (e.g country-specific and operating COA) being used in the company. In this case the COA maintain alternative account numbers to the same account for automatic updation and consolidation.
    I hope this helps.
    Regards
    Kavitha

  • HT4623 I have just tried to update my Iphone 5 and its jow stuck with the iTunes plug in sign, what do I do nomw?

    I have just tried to update my iPhone 5 adn its stuck with iTunes plug in sign, I have always used my I CLOUD.
    Please someone help, Im lost without my phone!!

    Do this.
    Turn your phone off: When you get to that itunes plug in sign, press and hold the power and home button until your screen goes black, and release those buttons when it goes black. ( make sure your phone is not plugged in your pc yet).
    Now your phone is off.
    Next do this: Press and hold power+home button for exactly 10 seconds, after 10 seconds pass, release the power button but keep holding your home button for exactly 13 seconds.
    Now plug in your usb cord to your pc and then to iphone, and open up itunes. Itunes should say that there is a device in recovery mod discovered , and simply press RESTORE. Your iphone will restore and you'll be able to use your phone.
    Reply with results or questions.
    Hope I helped.
    Donnie.

  • How do i stop a new session having the last sessions pages, i have tried "when firefox starts.." and about:config fixes with no luck...

    Every time i load FF4 i get the last sessions pages. I have looked thru forum and tried about:config changes - no luck. ALso the "when firefox starts" fixes - no luck. every is set properly but it doesnt stop FF4 from restoring previous session.. so annoying as my first bug with FF4!

    Make sure that you close Firefox properly.
    See "Hang at exit":
    * http://kb.mozillazine.org/Firefox_hangs
    * [[Firefox hangs]]

  • Distinct and sum in alv report

    i have 6 row of 1 matnr
    and i have to display only 1 with the sum of each field
    example:
    300032   3 4 1
    300032   3 3 3
    300032   2 2 2
    i want
    <b>300032   8 9 7</b>
    how?
    thanks.

    Hi
    Use Collect statament to append the record to output table.
    DATA: BEGIN OF ITAB OCCURS 0,
            KEY
            FIELD1 TYPE I,
            FIELD2 TYPE I,
            FIELD3 TYPE I,
          END   OF ITAB.
    ITAB-KEY = '300032'.
    ITAB-FIELD1 = 3.
    ITAB-FIELD2 = 4.
    ITAB-FIELD3 = 1.
    COLLECT ITAB.
    ITAB-KEY = '300032'.
    ITAB-FIELD1 = 2.
    ITAB-FIELD2 = 2.
    ITAB-FIELD3 = 2.
    COLLECT ITAB.
    ITAB-KEY = '300032'.
    ITAB-FIELD1 = 3.
    ITAB-FIELD2 = 3.
    ITAB-FIELD3 = 3.
    COLLECT ITAB.
    Max
    Message was edited by: max bianchi
    Message was edited by: max bianchi

  • LINQ Group and Sum table

    I can't figure how to group those records 
    EmpID
    ClientId
    HourIn
       HourOut
            Date
    TotalHours
    12345
    9999
    8:00 AM
    12:00 PM
    01/05/2015
    4
    12345
    9999
    1:00 PM
    3:00 PM
    01/05/2015
    2
    12345
    9999
    3:30 PM
    6:00 PM
    01/05/2015
    2.5
    12345
    9999
    8:00 AM
    5:00 PM
    01/06/2015
    9
    12345
    9999
    8:00 AM
    5:00 PM
    01/07/2015
    9
    12345
    9999
    8:00 AM
    5:00 PM
    01/08/2015
    9
    12345
    9999
    8:00 AM
    5:00 PM
    01/09/2015
    9
    I want to group by date and sum total hours and hourin in the first and hour out is the last one. 
    FYI (date can be datetime) (eg i can make date to be (1/18/2014 12:00:00 AM)
    EmpID
    ClientId
    HourIn
    HourOut
    Date
    TotalHours
    12345
    9999
    8:00 AM
    6:00 PM
    01/05/2015
    8.5
    12345
    9999
    8:00 AM
    5:00 PM
    01/06/2015
    9
    12345
    9999
    8:00 AM
    5:00 PM
    01/07/2015
    9
    12345
    9999
    8:00 AM
    5:00 PM
    01/08/2015
    9
    12345
    9999
    8:00 AM
    5:00 PM
    01/09/2015
    9
    Thanks in advance

    Hope this helps..do a group by and then select ..change the below accordingly
    DataTable objtable = new DataTable();
    objtable.Columns.Add("EmpID", typeof(int)); objtable.Columns.Add("ClientId", typeof(int));
    objtable.Columns.Add("HourIn", typeof(DateTime)); objtable.Columns.Add("HourOut", typeof(DateTime));
    objtable.Columns.Add("Date", typeof(DateTime)); objtable.Columns.Add("TotalHours", typeof(double));
    objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/05/2015 8:00 AM"), Convert.ToDateTime("01/05/2015 12:00 PM"), Convert.ToDateTime("01/05/2015"), 4);
    objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/05/2015 1:00 PM"), Convert.ToDateTime("01/05/2015 3:00 PM"), Convert.ToDateTime("01/05/2015"), 2);
    objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/05/2015 3:30 PM"), Convert.ToDateTime("01/05/2015 6:00 PM"), Convert.ToDateTime("01/05/2015"), 2.5);
    objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/06/2015 8:00 AM"), Convert.ToDateTime("01/06/2015 5:00 PM"), Convert.ToDateTime("01/06/2015"), 9);
    objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/07/2015 8:00 AM"), Convert.ToDateTime("01/07/2015 5:00 PM"), Convert.ToDateTime("01/07/2015"), 9);
    objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/08/2015 8:00 AM"), Convert.ToDateTime("01/08/2015 5:00 PM"), Convert.ToDateTime("01/08/2015"), 9);
    objtable.AcceptChanges();
    var result = objtable.AsEnumerable().GroupBy(x => x.Field<DateTime>("Date")).Select(g => new
    empId = g.First().Field<int>("EmpID"),
    clientID = g.First().Field<int>("ClientId"),
    hoursIn = g.Min(e => e.Field<DateTime>("HourIn")),
    hourOut = g.Max(e => e.Field<DateTime>("HourOut")),
    totalhours = g.First().Field<double>("TotalHours")
    foreach (var row in result)
    Console.WriteLine("{0} {1} {2} {3} {4} ", row.empId,row.clientID, row.hoursIn.ToString("HH:mm tt"), row.hourOut.ToString("HH:mm tt"),row.totalhours);

  • Can't get Headphone and Mic to work with Skype

    Hello, I have a 3 year old Macbook Pro and I am running OS 10.8.3. I am trying to get my USB headphone and mic to work with Skype but I'm not having any success. I have tried several different headphones with the same result. I finally phoned Skype support and they told me that there are some registry settings that are corrupted and that they could install the proper ones on my MBP for $149.99. I told them I did not want to spend that kind of money but I am curious if anybody else is having that issue and if anybody has a solution. Is it true that my registry values could be corrupted causing this issue. If I start up Parallels and open Skype in Windows 7 I have no issues whatsoever using the headphone. It works every time but I cannot get it to work on the Mac platform. I would appreciate any advice anybody might have. Many thanks in advance.
    Dan

    I am trying to get my USB headphone and mic to work with Skype but I'm not having any success. I have tried several different headphones with the same result.
    What are the system requirements of your headphones & mics?  It's possible they are not compatible w/Macs and/or your current OS system. 

  • Webi  - How to use group by function and to make data distinct in that column

    Hi Everyone
    I'm a begginer in BO and i'm experiencing problems when trying to create a webi report that shows different courses, how many males and females in a course, their race and how many people attended each course. My challenge comes in wen i try to group by distinct courses:
    For Example
    Course name     Gender     Race         Attendees 
    BEXX11             Female     Coloured    2
    BEXX11             Male         African      1
    C3                    Male         Indian        2
    F3                    Female      White       1
    BEXX11            Female      Indian        3
    C3                   Female      Indian        4
    Course name     Gender     Race         Attendees
    BEXX11             Female     Coloured    2
                            Male         African       1
                            Female      Indian        3
    C3                    Male         Indian         2
                            Female     Indian         4
    F3                    Female      White       1
    Thanks in advance

    Hi Olebogeng Marumo,
    Apply the break on Course Name and then check the output.It will fulfill your requirement.
    Web Intelligence 4.0: Create breaks between groups of data
    Regards,
    Anish

  • Hi, I am having trouble getting an album to download. I have tried it on both my iPhone and laptop through iTunes but neither works. I am wondering if it could be the size of the album stopping it downloading (212 Tracks) Any Ideas?

    Hi, I am having trouble getting an album to download. I have tried it on both my iPhone and laptop through iTunes but neither works. I am wondering if it could be the size of the album stopping it downloading (212 Tracks) Any Ideas?

    These alerts occur due to timeouts or conflicts trying to write a file during download.
    If you encounter this issue while while downloading something from the iTunes Store:
    Delete your iTunes Downloads folder, located in:
    Mac OS X:
  ~/Music/iTunes/iTunes Media/Downloads   Note: "iTunes Media" may appear as "iTunes Music. Also, the tilde (~)  refers to your Home directory.
    After locating your iTunes Downloads folder:
    Quit iTunes.
    Delete the Downloads folder on your computer.
    Open iTunes.
    Choose Store > Check for Available Downloads.
    Enter your account name and password.
    Also review this support aticle as it might be causing due to internet connection: http://support.apple.com/kb/ts1368
    Hope this helps.

Maybe you are looking for

  • To Progressive Pic... Re: display

    Hi, Didn't get a chance to comment on your cracked display and it's closed now so I'm trying to communicate this way. I know it has the mini-VGA port, but I'm wondering about the resolution. Depending on your model (according to Mactracker): The orig

  • Having difficulty converting more than one page of a PDF to Excel.

    I am using Adobe Acrobat 10.0 to convert PDF files to use in Excel. I am working with PDFs that have several dozen, if not hundreds of pages, almost all of which contain very lengthy tables. I need to have these tables saved in a format accessible by

  • Adding links to Images

    How do I add links to images? Unfortunately, I am unable to add a link to an image in my document.  I selected the image but the "add link" option is grayed out.  The inspector feature is very different in this new version and I am unable to figure o

  • How do I keep iPhoto '09 active on the dock

    How do I keep iPhoto '09 active on the dock, similar to itunes when the window is closed... It's so annoying when I close the window... and then when I open it later on, it has to load all the pictures again! Is it possible to keep it active, even if

  • Cross Company - STO

    Hi All, I am facing a error in Cross Company - STO. After creating Purchase Order and releasing it on the vendor (which is a plant belonging to another Company Code), during PGI it is throwing an error, " Purchase Order 45......... does not contain i