Excluding count/distinccount when item is in multiple groups

Hello reader,
Currently These are my groups from a single  table (column left = CustomerID, column right = Status)
Group A contains:
A_Cust_12      1
A_Cust_13      6
A_Cust_14      3
A_Cust_15      1
Group B contains:
B_Cust_75      3
B_Cust_76      5
B_Cust_77      3
B_Cust_78      1
Group Special contains:
A_Cust_12      2
So far the columns from a table.
I grouped them as you can see. I want to know the distinctcount of CustomerID in each group, having state 1.
But...
Look at A_Cust_12. This CustomerID is also to be found within group Special. And in group Special it has Status 2. therefore, the A_Cust 12 in group A is not to be counted.
State 1 means "paid". But when the customer is in Group Special with State 2 (and 2 only) then something went wrong with the payment. Anyone in Group A or B can only have the same CustomerID in group Special only. A can not occur within group B for example. So if it's in group "Special" with a certain state, then don't count it.
So the real count of CustomerID's in group A = 3. Number 12 doesn't count.
How do I do this?
I've worked on this for a full day but I can't get it for the life of me.
Please do mind that more groups can (and will) exist, but there is only one group "Special".

I've solved it. Took me a bit. Do this:
Step 1. Create:
Group 1: group by "Group A" & "Group B" by ascending order (important!)
Group 2: group by CustomerID, ascending order (important!)
Step 3. Create the groupname you'd like to summarize on using a formula (trick) then place it in the group footer 1.
@MyGroupName
WhilePrintingRecords;
global stringvar GroupName;
@CustomGroupNameTrick
If {SomeTable.SomeColumn} <> "Group Special" then
GroupName:= {SomeTable.SomeColumn} else
GroupName;
Step 4: create a formula to count the states 1 (paid). Later we'll create a formula to correct this final sum with states 2. Place in detai section
@State_Paid
if Not({SomeTable.State} In [1]) and {SomeTable..OBCampaign_ID} <> "Group Special" then 1 else 0;
Create a sum on this formula (manual running total by making a new formula, using the SUM() function.
Create formula to count the states 2 (something went wrong with payment).
Create  a manual running total on this formula.
Then substract: @State_Paid - @State_PaymentWentWrong
So the formula part is fairly straight forward. However, the tricks are twofold:
1) Create 1st group on the column that you want to group on (don't bother why, because you'll surpress the g. header)
2) Create 2nd group on CustomerID, ASCENDING order. (important to use tricks by knowing Crystal Reports behaviour). Supress this too.
3) Use the groupname workaround formula ( @CustomGroupNameTrick ). Place in groupfooter 1.
From there, you have a very nice setup to report on2  loosely related tables.

Similar Messages

  • HT1451 when editing info, how do i select multiple items to edit a group? For example, changing the artist name on multiple tracks at once?

    when editing info, how do i select multiple items to edit a group? For example, changing the artist name on multiple tracks at once?

    Same way you select multipl items anywhere else.
    Hold ctrl and click the items you want.
    If they are in consecutive order, click the 1st then Shift click the last.

  • How to count number of items present in a data block

    hi all,
    how to count how many items present in a particular data block in oracle forms 10g.
    whether it is a text_item or display_item or list_item etc is there any method to do this.
    please reply....

    hi all,
    i have written this when-button pressed but the problem is how to get the next item name in the block
    DECLARE
         V_COUNT NUMBER:=0;
         V_FIRSTITEM VARCHAR2(100):='';
    BEGIN
         GO_BLOCK('BLOCK_ITEMCOUNT');
         V_FIRSTITEM := GET_BLOCK_PROPERTY('BLOCK_ITEMCOUNT', FIRST_ITEM);
         LOOP
              V_COUNT := V_COUNT + 1;
              EXIT WHEN GET_ITEM_PROPERTY(V_FIRSTITEM, NEXTITEM) IS NULL;
              --V_FIRSTITEM := GET_BLOCK_PROPERTY('BLOCK_ITEMCOUNT', NEXTITEM);
              --V_COUNT := V_COUNT + 1;
         END LOOP;
    END;

  • Play count for imported items

    Here's a new one for me...
    Starting with this latest version, when I burn a CD, it automatically marks the Play Count for those items at 1. Anyone else encounter this? Is there a fix?

    i've noticed that sometimes the play count does not increase for songs, and the only workaround i've seen that works is to do a second sync after the first one completes.

  • I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    Logged the call with SAP who directed me to 'Define settings for attachments' in IMG and setting the 'Deactivate Java Applet' & 'Deactivate Attachment versioning' checkboxes - problem solved.

  • How do you get rid of white space when you are printing multiple pages to one sheet of paper?

    How do you get rid of extra white space when you are printing multiple pages to one sheet of paper?  When printing multiple pages to one sheet of paper Acrobat won't let you select the "zoom" for printing.
    Thanks

    Take a look at Quite Imposing.

  • I have three airports connected to my computer but when i ask for multiple speakes on the streaming section it only allows two of them at a time.. is there a way to have all airports streaming at the same time to different speakers.

    when i hit the multiple speakers option on streaming music in itunes to my airports which i have three connected, it only ever brings up two maximum plus the computers internal speaker as an option. how do i configure the computer t allow all three airports to stream the itunes content

    when i hit the multiple speakers option on streaming music in itunes to my airports which i have three connected, it only ever brings up two maximum plus the computers internal speaker as an option. how do i configure the computer t allow all three airports to stream the itunes content

  • I can no longer (since upgrading to the latest firefox) open up multiple tabs of the same page (something I need to be able to do when emailing and referencing multiple emails while writing one email). The only option it gives me is to 'switch to tab'.

    Question
    I can no longer (since upgrading to the latest firefox) open up multiple tabs of the same page (something I need to be able to do when emailing and referencing multiple emails while writing one email). The only option it gives me is to 'switch to tab'.

    I'll try to make this clear. I USED to be able to left click on a hyper link and the hyper link would open in a NEW tab. Now for some unknown reason the hyper link by default opens in the same tab (window). I have to right click the hyper link in order for it to open in a NEW tab. (Yes, my 'tools'> 'options'> 'tabs' are set to "open new windows in a new tab." (Please no answers telling me to get rid of the Ask toolbar because I don't have one.) Thank you.

  • Count (case when) not working in sql

    Hi All,
    I am trying to find the count of members for a perticular date range, it seems not working correclty.
    Could any one help me out.
    here is the query...I am getting same output for all the cases..please help
    Select
    t
    .MemberNbr,t.patcom
    count(case
    when
    datediff(d,
    mbrs.DischargeDate,
    convert(datetime,convert(varchar(12),t.specificdateofservice),112))
    between
    -1
    and
    -365
    then t.MemberNbr
    else 0
    end)as
    edvisits365daysprior
    count(case
    when
    datediff(d,
    mbrs.DischargeDate,
    convert(datetime,convert(varchar(12),t.specificdateofservice),112))
    between 1
    and 3
    then t.MemberNbr
    else 0
    end)as
    edvisits3Days
    count(case
    when
    datediff(d,
    mbrs.DischargeDate,
    convert(datetime,convert(varchar(12),t.specificdateofservice),112))
    between 1
    and 30
    then t.MemberNbr
    else 0
    end)as
    edvisits30Days
    count(case
    when
    datediff(d,
    mbrs.DischargeDate,
    convert(datetime,convert(varchar(12),t.specificdateofservice),112))
    between 1
    and 60
    then t.MemberNbr
    else 0
    end)as
    edvisits60Days
    count(case
    when
    datediff(d,
    mbrs.DischargeDate,
    convert(datetime,convert(varchar(12),t.specificdateofservice),112))
    between 1
    and 90
    then t.MemberNbr
    else 0
    end)as
    edvisits90Days
    --,*--membernbr,specificdateofservice,count( membernbr)--, specificdateofservice)as visitcount--, patcom
    --Into #Tmp_PPCSEDCnt1
    From
    stg_tbl_InPatientPrepost Mbrs
    join
    #Tmp_MCCSEDVisits t
    on
    mbrs.MemberNbr=t.MemberNbr
    --where UPPER(t.MR_Line_Desc) in ('FOP EMERGENCY ROOM - HOSPITAL', 'FOP EMERGENCY ROOM Urgent Care',
    --'PROF ER VISITS AND OBSERVATION CARE')
    group
    by t.MemberNbr,t.patcom

    You may replace 0 as NULL and see how it works for you?
    eg:
    count(case when datediff(d, mbrs.DischargeDate,
    convert(datetime,convert(varchar(12),t.specificdateofservice),112)) 
    between -1 and -365 thent.MemberNbr else NULL end)as edvisits365daysprior

  • I would like to know how to get the unrestricted quantity excluding actual customer ordr quantities on a given group of items?

    I would like to know how to get the unrestricted quantity excluding actual customer ordr quantities on a given group of items?

    Hi , Welcome to the HP Forums!
    It is a terrific place to find answers and tips!
    For you to have the best experience in the HP forum I would like to direct your attention to the HP Forums Guide.Learn How to Post and More I grasp you would like to replace the keyboard and would like the part number and where to purchase one. Here is a link to the HP Pavilion 17 Notebook PC HP Pavilion 15 Notebook PC Maintenance and Service Guide .  Please note chapter 3, page 20, item 2 for the replacement keyboard part numbers. You stated you were having a difficulty locating where to purchase the part.  Here is a link to  HP Notebook PCs - Ordering HP Certified Replacement Parts for your convenience. You can also try a Google search with the part number for other vendors that may have one.   To say thanks for replying please click the thumbs up icon below. If this has addressed your query please choose solution provided to help other people locate this information.   Best of Luck!

  • Particular sales order of the same line item hv created multiple production

    sir,
    I am having a problem in MD04. A particular sales order of the same line item hv created multiple production order.and continously planning is going on... I didn't get why it happens.
    Will u please suggest me what should i do in this case?
    Regards
    Meenu

    Hello sir,
    yes, ofcourse, for the finished material have the BOM with some semifinished productes which are to be produced .
    In co02 , we can go through the collective production order.
    One more thing is that, in the multiple production order date(scheduling date) shows in forward(future dates).
    For ex:09-05-2010.
    Regards
    Meenu

  • How count number of item records in a File: Idoc to File scenario

    Hi All,
    I am configuring an IDOC to File scenario.
    Once all the IDOC data is dumped on a File, I need to calculate the number of Item records in this file and write this number at the end of the trailer record in the file.
    Is theer a way to calculate the item data records(or say number of lines in the file) in the message mapping area. Or any other simple way to do it.
    Appreciate your help on same.
    Thanks
    Shirin

    hi,
    Use the count function for ITEM node the assign this count value to the receiver field , keep the ITEM context to header!
    Thanks,
    Vijaya.

  • Why is the word count different when I use word count from the tools menu to the number at the bottom of my mac word document

    Why is the word count different when I use word count from the tools menu to the number at the bottom of my mac word document

    This forum is for Apple's defunct office suite 'AppleWorks' - since the word count is not in the places you mention I assume you are talking about Microsoft Word? Though it's just possible someone in this forum might also use Word and know the answer, you would stand a higher chance of getting an answer in Microsoft's own forums. You could also try asking in the forum applicable to your operating system - Lion, Mavericks or whatever - on the reasonably chance of finding someone familiar with Word.

  • Finding out when items will be added to Apple TV iTunes store.

    Is there any website or place to find out when items are going to be added to the iTunes store. For example I`m currently watching the 3rd season of Bones from the iTunes store on my Apple TV, but there are only the first 12 of the 15 episodes up for sale. How do I find out when the last 3 are going to be added?
    Thanks

    No one here can answer that question. Discussion of future Apple plans violates the TOU.
    Your bank should know - at some level - if or when that might happen.
    Barry

  • Change Purchase Requisition Document Type when item category is D

    Hi experts,
    i have problem, when i put servis number in to the servis line i havent change Purchase Requisition Document Type. Account
    Assignment Category is K and Item Category is D. It is standard of Purchase Requisition? When i set that i can change document type when item category is D.
    When i putting only material i can change Purchase Requisition Document.
    Thx for your answer.
    Laco

    Hi,
    One thing please note that once you select the document type and draft the PR and save the PR, you will  get the doc number.
    Once you get the document number you cannot change the PR document type .
    The reason is document type is linked with number range so it cannot be changed because different seriers of document number is assined to differentdocument type. 
    And moreover document type is linked with the screen settings also. So I would request you to check the settings for each doc. type

Maybe you are looking for