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

Similar Messages

  • Has anybody fixed the play count issue?

    Hey up, been having problems with play counts noy syncing and read about others with the same problems...  Ive updated to iOS 5.1 and still the same issues. Rating are fine but thats about all!

    It works, but it's still a bit quirky.
    For me, it didn't work at all until this past Sunday (March 11) when iTunes on my Mac mysteriously turned turned Match off by itself. When I turned it on again (it went through the whole process of scanning and updating, but only took a couple of minutes), the play counts updated with the information from my phone. It's  been working for me since then.
    So if it's not working for you, I suggest making sure you have the most recent version of iTunes and turning iTunes Match off (in iTunes on your computer, not necessarily on your phone or IOS device), then turning it on again.
    Sometimes it takes a long time for the information to show up. I think iTunes is still only periodically checking for changes, maybe once a day or when you log in to the iTunes store, etc. Sometimes the 1st song I play on the phone will be reflected on the Mac almost immediately, and the rest take a while longer to show up.
    I don't track my play counts closely, I really don't care much about them, so I don't know if they are updating correctly. People in other discussions report seeing one play count as two and some other oddities - but I notice that things I play on my phone do show up (within a day or so) in my "recently played" playlist on the Mac.

  • Is there a better approach to show the distinct count measures?

    Experts,
    I have a requirement in which I want to diplay 20+ calculated columns. The coulmns are something like this..
    No of clients with income < 10000 (to check against sales measure in fact table)
    No of Clients with sales > 500000 (to check against sales measure in fact table)
    No of clients whose join date > 1st jan current year ( to check against cust_start_dt of client Dim)
    No of clients with size "Medium" (to check agains a column client_size of Client Dim)
    No of clients with sell product units > 500 (Need to check units in PROD Dim)
    and so on..
    Well, I can write a case statement using expression builder for each column in the criteria, but the report performance is very bad. My client dimension is a huge partitioned table. As I keep on adding columns, the report takes more time to fetch data and at some point it never comes back.
    We tried to push to calculations to database, but since users can provide any selection criteria from dashboard prompt, it doesn't seem to work.
    If anyone had done any similar request in the past, please direct.

    Jared,
    Thank you for responding to my posted message. Rendezvous is a new concept to me, maybe
    it's the solution to my problem. I have been trying to read the on line manual and
    example VIs from National Instruments website. I still have a hard time to understand
    the concept.
    One of the example I saw is using rendezvous to run some sub VIs. But in my case, I have
    only one VI that is a while loop. Inside the while loop, there are a few tasks running
    simultaneously. I don't know whether it will serve my purpose.
    Guangde Wang
    Jared O'Mara wrote:
    > Guangde,
    >
    > Referring to your 2nd method, use rendezvous (under advanced>>synchronize
    > on function palette) to synchronize two processes. There are good examples
    > that come with labview. basically, you cre
    ate a rendezvous, giving it a
    > size. Using the wait on rendezvous vi, a function will not continue until
    > all rendezvous have reached that point. Using this method, you can synchronize
    > your 2 while loops.
    >
    > Jared
    >
    > Guangde Wang wrote:
    > >I tried two ways to control the tempo of my program.>>One is to use the
    > While Loop's counter and a wait. The drawback of this>method is the cycle
    > length is dependent on the measuring load. So if the>program runs for days,
    > it will be significent off the real time.>>The other way is to use the difference
    > of the Tick Count. It provides>accurate timing but the problem is the sychronization
    > of the clock cycle>and the While Loop cycle. I can try to put a little bit
    > wait but still>can not sychronize them very well. So after a while, there
    > will be two>measures get together.>>I don't know whether there are some better
    > ways to control the program>or whether we have some ways to improve either
    > or both of the above
    two>methods to make them work better. Please let me
    > know if you have any>suggestion.>>Thank you in advance,>>Guangde Wang>

  • Error: The sort order specified for distinct count records is incorrect

    When processing a measure group with a distinct count measure in it, i get the following error:
    "The sort order specified for distinct count records is incorrect."
    I have no idea what this means - any ideas?

    I had the same problem and your fix worked.  In more detail, the problematic field was contract_no.  I added a named calculation to the table in the Data Source View with the formula CHECKSUM(contract_no).  Then I created the distinct count measure on that named calculation.  And, lo and behold, the errors disappeared! 
    Thank you to Frank.
     - CindyCindy P Hoskey

  • Distinct count mdx fails

    Hi,
    I have a question about performing a distinct count of number of clients in my cube OLAP. 
    My clients-dimension table is populated from 4 different databases, this means that I can find the same clients with different Clients_ID (Natural key), because each client has a different ID in every database.  
    I want to calculate a distinct count on client’s phone number because it’s the same record in all Databases, I always get a big number which is not the right result.  I checked deeply the issue and I found that the query I set seems
    to not perform the distinct count right on the phone number.
    The small test I did with only filters (see screenshot below) let me believe that my query is performing the distinct count on each client ID instead of the phone number.
    Here it is the query I used to perform my distinct count:
    WITH SET MySet AS
    Filter(
    {[Dim Date].[Year].&[2014]} *
    {[DIM FA Clients].[FaCuNumberX].[FaCuNumberX]},[Measures].[QQT - Fact Ventes]>1 or [Measures].[QQT - Fact Ventes]=1)
    MEMBER MEASURES.SETDISTINCTCOUNT AS
    DISTINCTCOUNT(MySet)
    SELECT {MEASURES.SETDISTINCTCOUNT} ON 0
    FROM [CubeAll]
    I don’t know why the filter on this mdx query doesn’t work properly like an SQL group by.
    Thanks for help! 

    Hi Merouane,
    According to your description, you want to calculated to the numbers of client by count distinct Phone Number, right?
    In your scenario, you can add a distinct count measure in your project. Distinctcounts are one of the most demanding requests that can be placed on a MOLAP database, caused by the large number of dimensional attributes that typically exist in a cube. Here
    is a blog which describe several solutions for distinctcount in a SSAS project, please refer to the link below to see the detais.
    http://www.mssqltips.com/sqlservertip/3043/different-options-for-creating-a-distinct-count-measure-in-ssas/
    Regards,
    Charlie Liao
    TechNet Community Support

  • 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,

  • Distinct count of dimension business key in fact table

    In my cube I have a fact table which joins to a patient dimension.  The patient dimension is a type 2.  What I would like to do is get a distinct count of patients who have records in the fact table.   The business key in the patient dimension
    is the PrimaryMrn.  So a SQL query would look like this.
    SELECT count(distinct PrimaryMrn)
    FROM EncounterFact e
    INNER JOIN PatientDim p
    on e.PatientKey = p.PatientKey
    Is it possible to do this via MDX?
    Thanks for the help.

    If you have to distinct count an attribute in a SCD 2, you might choose between:
    Denormalizing that attribute in the fact table, and the create a classical DISTINCT COUNT measure
    Use a many-to-many approach - see the "Distinct Count" scenario in the Many-to-Many White paper here:
    http://www.sqlbi.com/articles/many2many (for both Multidimensional and Tabular
    If you use Tabular, you might want to read also this pattern:
    http://www.daxpatterns.com/distinct-count/
    Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo

  • 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.
    Tracy

    Deffinetly 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

  • SQL DISTINCT COUNT IN DATE RANGE

    Dear All
    Thanks for your attention.
    A table is storing the task summary of each order
    e.g.
    Date                            | Order Number    | Task Number
    2015-01-01 00:00:01   | ABC123456        | JOB001
    2015-01-01 00:01:02   | ABC123456        | JOB002
    2015-01-01 00:10:02   | ABC123444        | JOB001
    2015-01-01 10:12:59   | ABC123456        | JOB002   (Since the job002 is not done correctly, need to work again)
    2015-01-01 18:20:05   | ABC888888        | JOB001
    2015-01-01 20:22:42   | ABC789456        | JOB001
    2015-01-01 21:02:11   | BBB121212        | JOB002
    I would like to write a single query that get the distinct count of order number in sepcific date range
    result as expected in three columns:
    2015-01-01
    task_number            | AM | PM
    JOB001         | 2    | 2
    JOB002         | 1    | 1
    explain the figures here:
    JOB001 AM = 2 (ABC123456, ABC123444)
    JOB002 AM = 1  (two records of ABC123456 count as 1 since we would like to know the number of orders)
    JOB001 PM = 2  (ABC888888, ABC789456)
    JOB002 PM = 1  (BBB121212)
    I wrote a query get similar result but the count of order is not distinct
    SELECT task_number,
    AM=SUM(CASE WHEN date >= ('2015-01-01 00:00:00') AND date < ('2015-01-01 12:00:00') THEN 1 ELSE 0 END),
    PM=SUM(CASE WHEN date >= ('2015-01-01 12:00:00') AND date < ('2015-01-02 00:00:00') THEN 1 ELSE 0 END)
    FROM MyTable
    WHERE task_number = 'JOB001'
    Could anyone advise how to enhance this query to let the result become disintct of order number?
    Many Thanks,
    swivan

    Try
    select task_number,
    count(distinct case when datepart(hour, [date]) >=0 and datepart(hour, [date]) < 12 then [OrderNumbers] END) as AM,
    count(distinct case when datepart(hour, [date]) >=12 and datepart(hour, [date]) < 24 then [OrderNumbers] END) as PM FROM myTable
    GROUP BY Task_Number
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles
    Thank you very much,  short and good answer

  • Distinct count inside a measure group with other measures

    Hello,
    I have 1 distinct count inside a measure group with other measures, sum, count etc. I know this is not recommended due to poor processing performance and query response time.
    Processing performance I can live with if it means not having another measure group, which increases processing time anyway.
    I have used the recommended approach before and it generated many questions about what this second measure group is for (visible via excel), even though I made the distinct count appear in the main measure group via a calculated measure.
    (it would be nice if you could hide measure groups)
    However my question is: is query response time only effected when the distinct count is used in the query? Or is query response time effected regardless if the distinct count is used or not??
    Below is an extract from the 2005 distinct count optimizer white paper. It’s not completely clear but I assume if effects queries regardless if distinct count is used or not?
    "By adding other measures to the measure group holding a distinct count measure, all of the other measures will be at the same granularity as the distinct count measure, resulting in inefficient data structures and suboptimal
    queries."

    You might also be interested in reading this blog post, which deals with a similar scenario, to get a feeling for some of the things that might be going on behind the scenes:
    http://cwebbbi.wordpress.com/2012/11/27/storage-engine-caching-measures-and-measure-groups/
    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

  • 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.

  • Distinct Count Calculation

    Hello everybody,
    I have a cube with appointments including dimensions for companies and dates.
    One of my measures is "Appointments" which is the count of all appointments. Another calculated member is "Visits" which is the count of appointments with the type of "Visits".
    This is my MDX epxression for "Visits":
    AGGREGATE([Appointment].[Type].&[Visit], [Measures].[Appointments])
    Now I would like to create a new calculated member "Company Visits" which should be the distinct count of "Visits" by company and date.
    Example: 2 "Visits" in one company on the same day should be 1 "Company Visit"
    In T-SQL this query works:
    COUNT(
    DISTINCT(
    CASE [Type]
    WHEN "Visit" THEN CAST([CompanyID] AS NVARCHAR) + CONVERT(NCHAR(8), CAST([Date] AS NVARCHAR))
    ELSE NULL
    END
    ) AS [Company Visits]
    How can I do this with MDX in calculations?
    Additionally I would like to have a calculated member "Days in Field" as distinct count of dates with "Visits".
    Thanks in advance and best regards
    Lars

    Hi Lars,
    Based on your description, you want to create a new calculated member to calculate the distinct count of "Visit" for each company, right? In this case, you can use DistinctCount to achieve your requirement, here is a sample query about DistinctCount function
    for your reqerence.
    with member [DistCount] as
    distinctcount(exists(Employee.Employee.children,,"Reseller Orders"))
    Select {[Measures].[Reseller Order Count],
    [Measures].[DistCount]} on 0,
    ([Employee].[Gender].children) on 1
    From [AdventureWorks]
    Reference:DistinctCount (MDX)
    Regards,
    Charlie Liao
    TechNet Community Support

  • MSSQL2005 Analysis Service Distinct Count

    hi,
    i am currently trying to build a distinct count on my cube (mssql2005 analysis services).
    But after i added the discount count on the field i want to and start the processing, the following errors appear.
    - Errors in the OLAP storage engine: The sort order specified for distinct count records is incorrect.
    - Errors in the OLAP storage engine: An error occurred while processing the 'FACT VIEW STATISTIC' partition of the 'FACT VIEW  STATISTIC 1' measure group for the 'Accident Statistic' cube from the OLAP_PROJECT database.
    the count measure works fine.
    will appreciate any help on this distinct count problem.
    thanks in advance.
    HY

    I also received this error:
    "Errors in the OLAP storage engine: The sort order specified for distinct count records is incorrect. "
    Running SQL Server 2005 SP2 Enterprise Edition
    The collation between SQL Server and Analysis Services was the same.
    The distinct count was on a character data type.
    There were no NULLs in the data.
    The cube was processing fine until new data was added.
    After some investigation into the data it seems that the culprit was one row that the data length was 13 characters on the column of the distinct count. Everything else was less than 13 characters. (See results below). Updating this one row solved the problem. The exact value of the data is: '1-4296-175-9'
    Here is a result set:
    select len(columnname) as data_length, count(*) as count
    from [tablename]
    group by len(columnname)
    order by data_length
    data_length   count
    2    3
    5    1
    6    3
    7    2
    9    1
    10    856
    13    1
    My question though is if SQL2005 can do distinct counts on strings then why choke on one row with an extra length?

  • MeasureExpression property - Is there a possibility to implement distinct count with exclude empty?

    I have a measure which needs to have distinct count aggregation with exclude empty.
    Is there a possibility to specify MeasureExpression property to achieve the same? I have set the aggregation of the measure to none and I have typed the following function,
    Count(Distinct(Column_name),EXCLUDEEMPTY)
    where as the measure reads 0(zero) upon processing. Is there any other way to achieve this?
    The data feed has nulls included too for the column which this is to be achieved, which cannot be modified in the data level.
    Regards,
    Kantha Girish

    Hi Kantha,
    According to your description, you want to implement the distinct count aggregation, right? In this case, we can use a query like
    count(nonempty([DimName].[HierarchyName].[LevelName].members,[Measures].[MyMeasure]))
    Here are some blogs about how to implemet distinct count aggregation, please refer to the link below.
    http://blog.sqltechie.com/2009/09/distinctcount-analysis-service.html
    http://richardlees.blogspot.com/2008/10/alternative-to-physical-distinct-count.html
    If I have anything misunderstood, please point it out.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Sum Distinct Count

    Is there a way to sum a distinct count?
    I have a distinct count placed on GF2 and need the Sum of the Distinct count of GF1.
    Is this possible?
    Thanks for any help and suggestions,
    Jen

    Hi Jen,
    Try this:
    1) Create a formula on the Group Footer 2:
    WhilePringtingRecords;
    Numbervar dc;
    dc := dc + distinctcount({database field}, {group});
    2) Create another formula to display the sum and place this on the GF1:
    WhilePringtingRecords;
    Numbervar dc;
    3) Create a reset formula and place it on the GH1:
    WhilePringtingRecords;
    Numbervar dc := 0;
    -Abhilash

Maybe you are looking for

  • JSF Error Message not displaying/popping up in clickToEdit table

    I have an entity object validation rule which displays a message when the validation fails. I have set the Validation Failure Severity as an Informational Warning. I do want to user to continue if he is happy to do so. Everything works fine when test

  • MRP PR - As per Quota

    Dear All : We are runing MRP , want to generate PR as per source list  , quota arr. I defined source list  , quota arrangement , source list activated in mm master. Auto PO indicator in vendor master activated. PR getting generated. my question is :

  • Tab labels are grayed out except for active tab. This was not always the case. How to fix this?

    I recently had the 29 upgrade forced on me. I did not like the new lay out. I was trying different things and I hit the restore defaults button. After I did this, any tabs that I had open that were not the active tab, the labels was grayed out. I wan

  • It had nothing to do with our engineer! Honestly.....

    Before Christmas BT came and dug up the path outside our house and since then our phone line had developed a slight crackle. Slowly the crackle got louder and my broadband speed reduced to the level where it was nearly useless. I made the great mista

  • Why is Pathfinder crop tool removing items from artboard?

    Hello all, I have a complexe vector drawing with shapes that pass the artboard. I want to crop the items within the artboard without using a clipping mask. My problem is when I draw a rectangle equal to the artboard, place it on it's own in the top l