Distinct count in reports
I am doing a COUNT of accounts in my report. How can I achieve a DISTINCT count. Can this be done without using Virtual Key Figure?
Thanks
you mean you want to have a counter for each time an account gets added, like number of records in ODS?? I may have got your question wrong, but if all you need is a counter for your accounts , then you can create a characteristic for counter and add it in your report.
Similar Messages
-
Report using Tabular Model and Measures based on Distinct Counts
Hello,
I am creating a report that should present something like this:
YEAR-1 | MONTH-1 | MONTH-2 | MONTH-3... | YEAR | MONTH-1 | MONTH-2 | MONTH-3...
My problem is that when designing the dataset to support this layout I drag the Year, Month and Distinct count Measure, but on the report when I want the value for the YEAR level I don't have it and I cannot sum the months value...
What is the best aproach to solve this? Do I really have to go to advanced mode and customize my MDX or DAX? Can't basic users do something like this that seems so trivial and needed?
Thank you
Luis SimõesHi Luis,
According to your description, you create a Reporting Services report using Analysis Service Tabular Model as the datasource, now what you want is sum the months value on year level, right?
In your scenario, you can add the Month field to column group, add a parent group using Year Field and then add a Total on Month group. In this case, Reporting Services will sum the months value on Year level. I have tested it on my local environment, the
screenshot below is for you reference.
Reference:Lesson 6: Adding Grouping and Totals (Reporting Services)
If this is not what you want, please describe your dataset structure, so that we can make further analysis.
Regards,
Charlie Liao
TechNet Community Support -
Count distinct values in report builder
i have a situation where i have to count distinct number of customers.
i have a query which returns the list of values of bill_to_customer_id from ra_customer_trx_all table and i have to display only the number of distinct customers. i cant do this in the query because it has to be grouped and i am doing it in an aging report. i have to list the number of distinct customers in each aging period. can anybody please help me how to achieve this in reports 6i.
thankshow can i count distinct values in reports?
the situation is like this
i have a query which lists customer_id, invoice number, amount due
so what i want is to count the distinct customer_id and display the number of distinct customers. one customer_id can be repeated any number of times but i should count it only once. -
Distinct count of GRN's in Query PLD
hi all,
We have developed a daily grn report and designed report
using Query PLD.
Report contains
(grn no,date,vendor name,vendor ref no,item code,item
description,quanity & line total)
We want to display no of grn's(distinct count)
@ repetitive area footer.
Is there any function available in formula field to display
distinct count of no. of grn's ? / It should done thru query.
Thanks,
with regards,
A.Jeyakanthanit will be hard from PLD, instead u can have ur query like,
SELECT 'Details', ' ',T0.Docnum, T0.CardName, .... FROM OPDN T0 WHERE Month( T0.DocDate ) = Month ('{%0]')
Union
SELECT 'Counts', count(T0.DocNum) as 'Doc(s) No', ' ', ' ', ... FROM OPDN T0 WHERE Month( T0.DocDate ) = Month ('{%0]')
(Replace { with [ )
Note ' ' is a gap in order to fill the other fields. in first query have given tht ' ' gap purposely so tht the display will not affect ur designing part
union is used b'coz Count() fn is like aggregate, so wont allow further individual fields coming along with it.
the 2nd query will occupy only one row, which by grouping u can separate and can hide from repetitive and take the value via formula field by writing that field's id to it into Footer Area.
Regards,
Dhana.
Edited by: Dhanalakshmi C on Mar 5, 2008 1:31 PM -
How do I solve this distinct count problem?
Hello experts,
So, I have an OBI report (table view). I needed to get the percentage difference btn 2 columns, I did. Then I had to summarize difference in 4 buckets (0-15, 16-30, 31-50, >50%); I did (case statement). NOW, I need to summarize(distinct count) the above buckets based on Store numbers for each day.
Basically, if the difference is btn(0-5%) and I have 5 stores then I need to see 5 stores separately. The problem I am having when I do the distinct count instead of having separate counts for each bucket I am getting the total. I see the buckets summarized, but the store column is showing the total number of all(we have about 700 stores) instead of breaking down the count for each bucket. In the stores column I am using the distinct count function, I don't know if the problem is here or the case statement for buckets. I don't know either OBIEE is able to do what I trying to do, since I have yet to do this kind of function. I have gotten few leads on my first post, so far none of them have worked.
As always, your insights are highly appreciated,Instead of using Distinct Count in Aggregation Rule,Try using in Column Formula.
Let me know if u need any help on this.
Thanks, -
Running Total & Distinct Count Query
Crystal 10.0.0.533 CR Professional
Hope you can assist.
I have a report listing deals signed, each deal has a corresponding category i.e. industry type, Accountant, Chiropractor, Financial Services, etc.
I am undertaking a Distinct Count on these categories so that in the group footer it is showing number of different categories signed in a period (the report is grouped into different date periods). This is working OK.
However, I need to EXCLUDE the category from this distinct count if the deal value is zero.
I have tried using a formula to show a blank field if the value is zero, however it appears to be distinctly counting the blank as a category?
Any assistance would be much appreciated.
TracyDeffinetly it will be less than what you expect for grand total. It is because when you are calculating distinct count for each group suppose
Group A has categories A,B,C,D-->distinct count (4)
Group B has C,D,E,F-->distinct count (4)
but while calculating grand total then the distinct count will be
A,B,C,D,E,F --> grand total (6) but not (8).
In this case you need to use mannual running total like this
whileprintingrecords;
numbervar i;
i:=i+{running total};
place this in group footer and create another fomula like this
whileprintingrecords;
numbervar i;
place this in report footer to get the correct grand total.
Regards,
Raghavendra -
Distinct Count Function-how to use properly
Hello,
I am new to using forums & have only been using Crystal since May of 2009, so i hope i do this correctly & provide the appropriate information. i've looked for this answer in what's been posted but cannot find it. Some things i've read I don't really understand. I only know how to use the functions that are in the software, i don't know how to write them myself (i think that's when people have referred to SQL code or basic syntax)
I have CR Professional, version 11.0.0.1282 (Crystal Reports XI).
I work at a county health dept and we have a annual medicaid cost report, I am linking Crystal to our EMR billing module. i have my report sorted by insurance, ie medicaid, bcbs, abw, hpm etc. and within each ins group i have the clients ID, DOS (date of service), procedure code, charge amt, ins pmt & patient pmt. i have totaled the charges & pmts for each group-works fine. i even have been able to create the formula to adj out the duplicate entries in the billing module (a service was entered wrong then adjusted out then re-entered correctly-without my formula crystal was pulling both these records and adding them to total charges.)
Where my problem lies and what my question is: I need to count encounters, an encounter is the visit, but each visit could have 2 or more procedure codes. So this results in multiple lines on my report for one visit, which i want for the charges to add correctly, but it makes my visit count to high. So I read about the distinct count function, of which there are three listed & i'm having a hard time understanding the differences. What i tried is: a distinct count of the acct ID-so the same acct ID's are only counted the one time. But some clients see us more than once per year, meaning the acct ID is the same but the DOS is different. For this client that would be 2 visits. But crystal is counting this as 1.
Saying what i want to do is this: Count as 1 when the acct ID and DOS are the same. I've tried using the different distinct counts but when i check my formula it always has errors. So I'm sure my lack of knowledge is what's holding me up-i fully believe crystal can do this.
Any help would be greatly appreciated.I create a dummy table, set up acc_id and DOS and Charge.
Created a running total
Summarized acc_id
Type of summary Count
Evaluated using a formula
<> previous ()
and reset on ACC_ID
My groups were sorted by acc_id and date
where there were multiple visits on the same DOS my count was 0
where the dos changed it would count accordingly.
You may need to use two Running totals to get the complete picture. -
I’ve been at this for two days now. Could someone lead me down the right path? Given the following data set:
create table data_owner.test_data
item_number varchar2(10 byte),
store_number varchar2(10 byte),
calendar_year varchar2(10 byte),
calendar_week varchar2(10 byte),
units_sold integer
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('1111', '31', '2010', '51', 4)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('1111', '16', '2010', '51', 2)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('1111', '31', '2010', '52', 3)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('1111', '27', '2010', '52', 1)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('1111', '16', '2011', '1', 3)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('1111', '27', '2011', '2', 5)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('1111', '20', '2011', '2', 4)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('2222', '27', '2010', '51', 3)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('2222', '16', '2010', '52', 2)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('2222', '20', '2010', '52', 1)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('2222', '16', '2011', '1', 3)
insert into test_data(item_number, store_number, calendar_year, calendar_week, units_sold)
values ('2222', '31', '2011', '2', 3)
select * from test_data
item_number store_number calendar_year calendar_week units_sold
1111 31 2010 51 4
1111 16 2010 51 2
1111 31 2010 52 3
1111 27 2010 52 1
1111 16 2011 1 3
1111 27 2011 2 5
1111 20 2011 2 4
2222 27 2010 51 3
2222 16 2010 52 2
2222 20 2010 52 1
2222 16 2011 1 3
2222 31 2011 2 3
My desired result is a sum of units sold and an accumulative distinct count of store numbers grouped by item, year, and week. i.e.:
item_number calendar_year calendar_week store_count sum(units_sold)
1111 2010 51 2 6
1111 2010 52 3 4
1111 2011 1 3 3
1111 2011 2 4 9
2222 2010 51 1 3
2222 2010 52 3 3
2222 2011 1 3 3
2222 2011 2 4 3
I can’t seem to get the store count right. I’ve been trying various methods of the count(distinct store_number) over (…) analytic function, but nothing works. Thanks.Hi,
Interesting problem!
When using analytic functions, you can't use both DISTINCT and ORDER BY. Too bad; that sure would be convenient.
The most general solution is to use aggregate functions instead of analytic functions, and do a self-join to pair every row ("table" l, for "later" in the query below) with every earleir row ("table" e below) for the same item:
SELECT l.item_number
, l.calendar_year
, l.calendar_week
, COUNT (DISTINCT e.store_number) AS store_count
, SUM (l.units_sold)
/ COUNT (DISTINCT e.ROWID) AS total_units_sold
FROM test_data e
JOIN test_data l ON e.item_number = l.item_number
AND e.calendar_year || LPAD (e.calendar_week, 2)
<= l.calendar_year || LPAD (l.calendar_week, 2)
GROUP BY l.item_number
, l.calendar_year
, l.calendar_week
ORDER BY l.item_number
, l.calendar_year
, l.calendar_week
;You might think about storing a DATE (say, the date when the week begins) instead of year and week. It would simplify this query, and probably lots of other ones, too. I realize that might complicate some other queries, but I think you'll fiond a net gain.
Thanks for posting the CREATE TABLE and INSERT statements; that helps a lot!
Edited by: Frank Kulash on Nov 18, 2011 12:48 PM
Here's an analytic solution. As you can see, it requires more code, and more complicated code, but it might perform better:
WITH got_r_num AS
SELECT item_number
, calendar_year
, calendar_week
, units_sold
, ROW_NUMBER () OVER ( PARTITION BY item_number
, store_number
ORDER BY calendar_year
, calendar_week
) AS r_num
FROM test_data
SELECT DISTINCT
item_number
, calendar_year
, calendar_week
, COUNT ( CASE
WHEN r_num = 1
THEN 1
END
) OVER ( PARTITION BY item_number
ORDER BY calendar_year
, calendar_week
) AS store_count
, SUM (units_sold) OVER ( PARTITION BY item_number
, calendar_year
, calendar_week
) AS total_units_sold
FROM got_r_num
ORDER BY item_number
, calendar_year
, calendar_week
;This approah will not work in all windowing situations. It's okay fo this job, but not if you wanted,for example, a count of distinct stores from the last 6 weeks, and the report covers more than 6 weeks. -
Use Variance for Distinct Count of Group Results
Post Author: Judith
CA Forum: Crystal Reports
Hi there,
I am new to CR. I am using CR 2008. I am stuck (every two minutes) and it would be great, if you could help me with this one:
I have a list of people who are talking to each other:A to B, B to A, C to D, D to A etc. Then I wanted to see, who has most friends and I have created Groups to have a Distinct Count on how many people are talking to A, and to B, and to C etc. that worked fine. What I would like to do is to find out is who of these has most people they are talking to. Or even better, what is the variance of the resulting subtotals. Simply using Variance or Maximum doesn't seem to work on the DistinctCount Summary.
I would very much appreciate any help on this.
JudithPost Author: Jagan
CA Forum: Crystal Reports
I understand the issue, I don't understand why you think DistinctCount at two different levels should total up. Consider this sample data:Facility, EmployeeA, 1A, 2B, 1B, 3
Facility A's distinct count => 2Facility B's distinct count => 2Report's distinct count => 3
Use DistinctCount() at the group level and create a formula to sum these counts yourself and print that in the report footer. -
Regular measures(measures with SUM function) are not working along Distinct count measures
Hi All,
I am creating a cube that got to have a distinct count measure and a sum measure. if i have created only sum measure then it is working fine. if i create both measures and process the cube only distinct count measure is populated. the sum measure is showing
all blank values. i am using 2008 R2, and creating 2 different measure groups for both measures, after i include the distinct count measure the sum measure becoming null. can you please help me with this? i am breaking my head for last 2 days on this.. Thank
YouRamesh, measures are affected by the context of the queries that contain them, for example and in some cases, you can get a different total count of something by two different queries, this is because the context of the first query is different than
the second one ... keep this in mind.
Now, I've noticed that you are "creating 2 different measure
GROUPS for both measures", and i guess that you are trying to view those two measures _which are from different measure
groups_ at the same time and in the same report.
considering the info in the first point and as you are create the calculated measures in two different measure
groups, I'm not sure but i guess that this is the problem, and i suggest you create those two calculated measures
in the same measure group, then try to view them again and let's see.
if the previous point didn't solve it, please post the expressions you are using to create the calculated measures, maybe this will help in finding the problem. -
The distinct count issue?
Hello experts,
So, I have an OBI report (table view). I needed to get the percentage difference btn 2 columns, I did. Then I had to summarize difference in 4 buckets (0-15, 16-30, 31-50, >50%); I did (case statement). NOW, I need to summarize(distinct count) the above buckets based on Store numbers for each day.
Basically, if the difference is btn(0-5%) and I have 5 stores then I need to see 5 stores separately. The problem I am having when I do the distinct count instead of having the counts separately for each bucket I am getting the total. I see the buckets summarized, but the store column is showing the total number of all(we have about 700 stores) instead of breaking down the count for each bucket. In the stores column I am using the distinct count function, I don't know if the problem is here or the case statement.
I know its Friday, still I believe there is someone who might have an idea on my dilemma.
As always, your insights are highly appreciated,Header 1
Header 2
Header 3
Header 4
Header 5
Header 6
Date
Store Count
Sales
Todate Sales
Difference %
Difference buckets
03/24/2013
698
716,374
717,011
-0%
0-15%
03/25/2013
698
583,335
583,793
-0%
0-15%
03/26/2013
698
220,640
220,886
-0%
0-15%
03/27/2013
698
236,803
188,150
215
11-30%
Header 8
Srini,
I am still not good at using OTN tables, but above is what I am talking about. Basically, The store count should not show the total count of all stores, instead it should show only distinct count that within the percentage bucket. As u can see it gives me the total, I made sure the aggregate rule isn't sum. By the way, could the problem be the case statement not the store column..
I also tried bucket and store only, still it shows the sum of all stores and not just distinct.
any idea -
Displaying Distinct Count as Grand Total
Hi -
I have a requirement where i have to show the distinct count of Transaction Numbers at the bottom of the report as Grand Total. I created a dummy column with Fx as MAX(RCOUNT(1)) and used it in Narrative view and it is showing me the total rowcount whereas i want the distinct rowcount based on Transaction number column in my report.
Any help is appreciated!
Thanks
RInstead of using a RCOUNT you can use the COUNT(DISTINCT <Transaction Number Column>) in your column formula
This is an inbuilt function.
Mark if it helps.. -
<p>I have a report that gets a distinct count of items per day.</p><p>DistinctCount(, , "daily")</p><p> I would like to create a running total of the daily count for a weekly grand total.</p><p>Thanks!</p>
<p>I'll take a stab at this - So I understand that the report is grouped by Day and looks like this:</p><p>GF1: 1/1/07 9</p> <p>GF1: 1/2/07 10</p> <p>GF1: 1/3/07 12</p> <p>GF1: 1/4/07 15</p> <p>GF1: 1/5/07 20</p><p> </p><p>The first thing I'd try is to create a another group on your Date field, this time selecting the grouping option to be "For Each Week". Take that group and move it so that it is Group1 and your current group is Group 2.... your structure will now look like this. </p><p>GH1: 1/1/07 < new 'week' grouping' > </p><p> GF2: 1/1/07 9</p> <p> GF2: 1/2/07 10</p> <p> GF2: 1/3/07 12</p> <p> GF2: 1/4/07 15</p> <p> GF2: 1/5/07 20</p><p> Then I would copy the Sum field (distinct count) that you are using in Group 2 and put it in the Group 1 footer. We could also create a formula to sum up all distinct counts per day, but a Distinct Count by week should accomplish what you are after. Then in a seperate formula, you could divide the DistinctCount of orders (by week) by the DistinctCount of dates (by week) to get your daily average....</p><p>formula:</p><p>DistinctCount ({Orders.Order ID}, {Orders.Order Date}, "weekly") <br />/ <br />DistinctCount ({Orders.Order Date}, {Orders.Order Date}, "weekly") </p><p> </p><p>Hope that helps. </p>
-
Distinct count of Group header
Hi Experts ,
I have a crystal report where i have grouped on Business area and group header carries YTD Actuals Vs Target
and in detail section it carries in different regions information ofthe business area.
Now my concern is i need to count distinct business area in report header based YTD Actuals <= or > Target.
Any Ideas!!!
Thanks,
KrishnaI am not sure if I am understanding what you are asking correctly, but here is my take on it.
You have a group that is identified as "Business Area"
You have done a calculation to determine the YTD Actual for each Business Area which you have put into the Group footer or header
Now you want at the report level a count of the business areas that have YTD actuals <= the Target, and a count of the business areas that have YTD actuals > the Target.
If this is correct, could you use a running total? In your field explorer pain, right click on Running Total and select New to open up the running total editor. In the summary section, select field to summarize on the field you used to define a business area; type of summary is "distinct count'; in the evaluate section, set up a formula to look for the YTD Actual <= to whatever the target was supposed to be; in the reset section, select never.
If this is not what you are trying to do, could you please reword your question? For example, are you trying to reshow each business areas YTD totals compared to the target in your report header instead of a count? -
Specified Order Grouping does not show if Distinct Count is Zero
Post Author: Hieu
CA Forum: General
Hello,
I'm using Crystal Reports XI R2 with SQL data source. I have a cross-tab report with grouping in specified order. It's a report of applicants applying to a college. The grouping is of various majors (degrees). The report summarizes (distinct counts) the number of applicants for the groups of majors. The problem is that if the count for a group of major is zero, then that Named Group does not appear at all in the cross-tab report. I want the Name Group to appear with the count of "0".
I notice this same phenomenon with specified order grouping anywhere and not just in a cross-tab. I have tried changing "convert database/other null values to default" but nothing working yet.
Any help will be most appreciated. Thanks.Post Author: synapsevampire
CA Forum: General
It's not a phenomenon, it's how databases and SQL works.
You didn't get any rows back for those with a zero distinct count (otherwise the count would be 1 or more, right?), so Crystal doesn't show any data for those groups.
So to display a zero for those that do not exist would reuire either advanced SQL, or manual summaries.
One method for manual summaries is to use Running Totals. Select distinct count of the applicants and group by the majors, then in the evaluate use a formula place:
{table.majors} = "Blah 1"
Creating a seperate Running Total for every group and replacing "Blah 1" with the various majors.
-kai
Maybe you are looking for
-
Impossible to install iTunes 10.5
Hello, I have been trying to install the new version of iTunes to be able to update my iPhone with iOS5 for weeks, but everything is impossible. When I try it there appears a message of windows error. Already I tried infinity of times uninstall the w
-
Hi all Can anyone please tell me how to convert a billing document to a pdf format file (code should take billing document number as input and give a file in the pdf format).
-
I just recently made the big jump to using final cut pro. Right off the bat I'm having trouble with importing video. The camcorder connects and imports video fine with Imovie HD, but when i use final cut pro it says that there is no connection in the
-
Video problems with solaris 10
Has any gotten solaris 10 working with an IBM Net Vista workstation? I am having problems with setting it up in desktop mode.
-
Failure to create a shared protection point during Windows Server 2012 R2 backup.
Several partitions on a system disk have been extended as well as the backup destination partition. After that Windows Server 2012 R2 failed the backup of a system disk with the following error message 0x8004230C. The Server stated it had failed to c