Distinct Count Measure on Dimension table via Bridge table.

Hi Team,
I have Dim_Devices Table, which is linked to other dimension like Dim_User  and Dim_City.
All these table has many to many relationship defined in bridge table i.e. B_Devices_User_City using referential keys.
I want to derive measure such as
Select Count(Dim_Devices[Device_Id])
where Dim_Devices.Validity_End_Date is null
Note : Device_Id and Validity_End_Date are present in Same Dim_Devices  Dimension Table.
Could you please help me to define cube structure and how to create such measure out of dim_table.

Hi Charlie,
Now, I have define DistinctCount Agreegation on Dim_Devices table which will use reference Relationship on B_Devices_User_City. My Count is correct.
 But, I came across one more issue, i.e. From Processed and deployed cube, I am trying to create off-line Cube/or Global Cube (I have given syntax below) which is for limited set of dimensions and measures, I found that It shows me error due
to such relationship.
Does it mean that, For Global Cube, Can't we use DistinctCount/Count agreegation?
CREATE
GLOBAL CUBE [Device OLAP_Cube_1_3]
Storage
'C:\Exportcube.cub'
FROM [Device DATA CUBE]
  -- Measures
  -- Cube

Similar Messages

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

    Ramesh, 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.  

  • How to join  2 star schemas  using a Dimensional table( like Bridge Table)

    How to join 2 star schemas using a Dimensional table( like Bridge Table) in OBIEE?

    Complex joins and Content levels is all you need, have you tried the forum search?

  • Issue Importing measures against dimensions loaded via SSIS

    Hi,
    We are new to BPC and currently working in a test environment.  We are having issues with importing measure data against dimensions that we are attempting to automate via SSIS.  I will apologize in advance for the long post, but want to give as many details as possible.
    Here is the scenario:
    We installed BPC v. 5.1 SP1 on SQL Server 2005, but have since installed SP2 and SP3.
    We created our own app set as a copy of AppShell.  We added some user defined dimensions and created a custom application as a copy of Finance.
    For initial testing, we loaded members into all dimensions via the Admin console and the Excel member sheets.  We also used the Import function in data manager to upload measure data into our custom application.
    We are now trying to automate the population of members for some of our dimensions (Entity and 4 user defined dimensions).  
    All of our data is mastered in SAP (we're on ERP 2005/ECC 6.0) with replications to our BI system (7.0).  We are using custom ABAP programs to create flat files for 3 of the dimensions.  For 2 dimensions, we are extracting from BI via Open hub.
    We have created SSIS packages to load data from the files into the relevant mbr tables.  We're taking things one step at a time and currently are processing the dimensions manually via the Admin Console - making sure that "Process members from member sheet" is unchecked.
    In our first attempts at loading dimension data via the SSIS package, we tried loading only a subset of the member data (forgetting about the measure data that had previously been loaded).  Because we were missing members in the load files for which measure data existed, we received data integrity errors upon processing the dimensions.  Once we loaded the full member data, the dimensions processed successfully.
    Our issue comes now when we're again importing measure data.  Before starting to "automate" our dimensions, I had successfully loaded several months worth of measures.  I had also tested clearing out one month of data.  Now, I am trying to reload that month of measure data.  I am using the same file as I had used previously, but the Import function is now rejecting all records.  The dimension members it is rejecting are valid dimension members, but they are all from dimensions we are attempting to automate.
    Has anyone encountered an issue like this before?  Even if you haven't, do you have any thoughts on what our issue might be?  Any help would be greatly appreciated!
    Thanks!
    Shannon

    There actually could be a couple different things.  The processing of the dimension could have encountered an error and therefore did not update the sql dim table association with the dimension.  You should check to see if the dimDIMENSION sql table actual have any members in it and if the members you are trying to load to are there.  If there were any errors in processing the mbr table the dim table will be empty.
    Also the automated update could have added extra character to the member name such as a trailing space which would actually make the dimension member name different than what is in the membersheet.
    In your automated dimension update, it would be a good idea to update the membersheet as well as the mbr sql table.  Then you can process the dimension from the sheet in the admin tool to troubleshoot any errors in your memberset. 
    - Sara

  • How to define an aggregation rule for a dimension based on bridge table?

    Hello,
    I need a solution for aggregating data correctly when using a dimension based on a set of dimensione tables containing a bridge table. Please find below a description of my business case and the OBIEE model which I’ve created thus far.
    Business Case
    The company involved wants to report on the number of support cases, the different types of actions that were taken and the people involved in those actions. One support case will undergo a number of actions (called ‘handelingen’) until it is closed. For each action at least one person is involved performing a specific role, but there can also be multiple persons involved with 1 action, each performing a different role for that action. This is the N : N part of the model.
    The problem that I face is visible in the two pictures below:
    http://i84.photobucket.com/albums/k24/The_Dutchman_2006/OBIEE/sample.png
    As long as I don’t include anything from the Dimension Meelezer in my report, I get the correct number of handelingen (7). When I include the person (called ‘Meelezer’), the measuere per action is multiplied by the number of persons/roles involved with that action.
    When I changed the Aggregation rule in the report column #Handelingen to ‘Server Complex Aggregate’ I do get the correct endtotal:
    http://i84.photobucket.com/albums/k24/The_Dutchman_2006/OBIEE/sample2.png
    I believe it should be possible to define in the repository a different aggregation rule for individual dimensions, but I’ve not been able to achieve this.
    Explained below is what I have created in my Physical and Business Model & Mapping layers:
    The Physical Model is built like this:
    (This is just a small part of a much larger physical model, but I’ve only included the most relevant tables)
    http://i84.photobucket.com/albums/k24/The_Dutchman_2006/OBIEE/PhysicalDiagram-1.png
    The Fact table (ALS Feit Zaakverloop) contains FK’s for the action (FK_HANDELING, joined to ALS Dim Handeling), the date the action took place (FK_DATUM_ZAAKVERLOOP, joined to ALS Dim Datum Zaakverloop) and the uniqe group of people involved (FK_MEELEZERS, joined to ALS Groep Meelezers) and a measure column (SUM_HANDELINGEN) populated with the value ‘1’ for each row.
    The Bridge table (ALS Brug Meelezer/Reden Meelezen) contains three FK’s: FK_GR_MEELEZERS (joined to ALS Groep Meelezers), FK_MEELEZER (joined to ALS Dim Functionaris) and FK_REDEN_MEELEZEN (joined to ALS Dim Reden Meelezen).
    The Business Model
    In the business model, the four physical tables for the N:N relation have been combined into one logical dimension table.
    http://i84.photobucket.com/albums/k24/The_Dutchman_2006/OBIEE/BusinessModel-1.png
    DIM Meelezer contains one LTS in which the four physical tables have been combined:
    http://i84.photobucket.com/albums/k24/The_Dutchman_2006/OBIEE/LTS1.png
    And all the required locical columns have been created:
    http://i84.photobucket.com/albums/k24/The_Dutchman_2006/OBIEE/LTS2.png
    DIM Meelezer has also been identified as a bridge table and a Business Key has been defined on a combination of the FK’s in the bridge table and business codes of the two dimension tables.
    http://i84.photobucket.com/albums/k24/The_Dutchman_2006/OBIEE/BMDIM.png
    Next a hierachy was created for Dim Meelezer:
    http://i84.photobucket.com/albums/k24/The_Dutchman_2006/OBIEE/Hier.png
    In Feit Zaakverloop, a measurement called ‘# Handelingen’ was created using SUM_HANDELINGEN, with an aggregation rule of SUM.
    In the LTS of both the DIM Meelezer and Feit Zaakverloop, the Logical Content Levels have both been set to: LVL Detail – Meelezer.
    Please provide suggestions that will NOT require changes to the physical datamodel as they would require too much time to achieve (or at leats would not be ready before my deadline.
    Thanks!
    Edited by: The_Dutchman on Dec 13, 2011 11:43 AM

    Hmm, no replies yet...
    Am I in 'uncharted territory' with this issue?

  • Calc problem with fact table measure used as part of bridge table model

    Hi all,
    I'm experiencing problems with the calculation of a fact table measure ever since I've used it as part of a calculation in a bridge table relationship.
    In a fact table, PROJECT_FACT, I had a column (PROJECT_COST) whose default aggregate was SUM. Whenever PROJECT_COST was used with any dimension, the proper aggregation was done at the proper levels. But, not any longer. One of the relationships PROJECT_FACT has is with a dimension, called PROJECT.
    PROJECT_FACT contains details of employees and each day they worked on a PROJECT_ID. So for a particular day, employee, Joe, might have a PROJECT_COST of $80 for PROJECT_ID 123, on the next day, Joe might have $40 in PROJECT_COST for the same project.
    Dimension table, PROJECT, contains details of the project.
    A new feature was added to the software - multiple customers can now be charged for a PROJECT, where as before, only one customer was charged.
    This percentage charge break-down is in a new table - PROJECT_BRIDGE. PROJECT_BRIDGE has the PROJECT_ID, CUSTOMER_ID, BILL_PCT. BILL_PCT will always add up to 1.
    So, the bridge table might look like...
    PROJECT_ID CUSTOMER_ID BILL_PCT
    123          100     .20
    123          200     .30
    123          300     .50
    456 400 1.00
    678 400 1.00
    Where for project 123, is a breakdown for multiple customers (.20, .30. .50).
    Let's say in PROJECT_FACT, if you were to sum up all PROJECT_COST for PROJECT_ID = 123, you get $1000.
    Here are the steps I followed:
    - In the Physical layer, PROJECT_FACT has a 1:M with PROJECT_BRIDGE as does PROJECT to PROJECT_BRIDGE (a 1:M).
    PROJECT_FACT ===> PROJECT_BRIDGE <=== PROJECT
    - In the Logical layer, PROJECT has a 1:M with PROJECT_FACT.
    PROJECT ===> PROJECT_FACT
    - The fact logical table source is mapped to the bridge table, PROJECT_BRIDGE, so now it has multiple tables it maps to (PROJECT_FACT & PROJECT_BRIDGE). They are set for an INNER join.
    - I created a calculation measure, MULT_CUST_COST, using physical columns, that calculates the sum of the PROJECT_COST X the percentage amount in the bridge table. It looks like: SUM(PROJECT_FACT.PROJECT_COST * PROJECT_BRIDGE.BILL_PCT)
    - I brought MULT_CUST_COST into the Presentation layer.
    We still want the old PROJECT_COST around until it get's phased out, so it's in the Presentation layer as well.
    Let's say I had a request with only PROJECT_ID, MULT_CUST_COST (the new calculation), and PROJECT_COST (the original). I'd expect:
    PROJECT_ID MULT_CUST_COST PROJECT_COST
    123          $1000     $1000
    I am getting this for MULT_CUST_COST, however, for PROJECT_COST, it's tripling the value (possibly because there are 3 percent amounts?)...
    PROJECT_ID MULT_CUST_COST PROJECT_COST
    123          $1000 (correct)      $3000 (incorrect, it's been tripled)
    If I were to look at the SQL, it would have:
              SELECT SUM(PROJECT_COST),
    SUM(PROJECT_FACT.PROJECT_COST * PROJECT_BRIDGE.BILL_PCT),
                   PROJECT_ID
              FROM ...
              GROUP BY PROJECT_ID
    PROJECT_COST used to work correctly before modeling a bridge table.
    Any ideas on what I did wrong?
    Thanks!

    Hi
    Phew, what a long question!
    If I understand correctly I think the problem lies with your old cost measure, or rather combining that with you new one in the same request. If you think about it, your query as explained above will bring back 3 rows from the database which is why your old cost measure is being multiplied. I suspect that if you took it out of the query, your bridge table would be working properly for the new measure alone?
    I would consider migrating your historic data into the bridge table model so that you have a single type of query. For the historic data each would have a single row in the bridge with a 1.0 BILL_PCT.
    Best of luck,
    Paul
    http://total-bi.com

  • Distinct Count Measure Total in Two Dimensions

    I have a report that pulls data Site and then drills down to User for Content Usage for Six Months. These are separate dimensions in the cube. I have a DistinctContent Measure that pulls for both Site and User appropriately when I use separate queries but it
    is at the lowest level which is User. A sum of DistinctContent at the Site level is not appropriate - it needs to be the DistinctContent for the Site, and then drill down to the DistinctContent for User.
    Aggregate cannot be used because there are filters on the report, and they have to be there for various reasons.
    I've tried Lookup but it only looks up for one field. Multilookup doesn't work either. 
    I've tried a drill down to a subreport so that the initial dataset would be for Site, and then the subreport is for User and uses a different dataset, but you cannot merge the cells so
    that the subreport fits nicely under the top level.  
    How do I get the DistinctCount for the top level, Site?  
    I'm currently working on creating a cube that will only count the distinct content by site and then combine the two cubes as a virtual cube as a workaround but I'm not sure of the full implications of a virtual cube.   I feel like I'm missing something
    because this seems to be something that everyone must need at some point right?  
    I'm beating my head against a wall.  Thanks so much to anyone who can help out.  I'm hitting the deadline, and everyone is stressing out because I've been working on this one issue for days and I'm the everything IT person, so other things are slipping.
    Here is
     (the abbreviated version of) the query:
    SELECT
    NON EMPTY
    {[Measures].[Distinct Content]} ON COLUMNS
    ,NON EMPTY
    Filter
    ([Site].[by Type].[Site].ALLMEMBERS
    ,[Measures].[Views] > 0)*
    Filter
    ([User].[by Type].[User].ALLMEMBERS,
    [Measures].[Views] > 0
    [Time].[Month Year].[Month Year]
    DIMENSION PROPERTIES
    MEMBER_CAPTION
    ,MEMBER_UNIQUE_NAME
    ON ROWS
    FROM
    SELECT
    {[Content].[by Domain Type Item].[Type].&[3]&[1]&[Art]} ON COLUMNS
    FROM [Cntnt]
    Here is a picture of the report currently.  Unique Articles is the measure I'm having issues with and you can see at the top level is the site name, and below that the user.
    Thanks so much to anyone who can help me out.  I really, really appreciate it. 
    Julia

    Hi Julia,
    Thank you for your question. 
    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
    Thank you for your understanding and support.
    Regards,
    Charlie Liao
    TechNet Community Support

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

  • 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

  • Distinct count for multiple fact tables in the same cube

    I'm fairly new to working with SSAS, but have been working with DW environments for many years.
    I have a cube which has 4 fact tables.  The central fact table is Encounter and then I also have Visit, Procedure and Medication.  Visit, Procedure and Medication all join to Encounter on Encounter Key.  The relationship between Encounter
    and Procedure and Encounter and Medication are both an optional 1 to 1.  The relationship between Encounter and Visit is an optional 1 to many.
    Each of the fact tables join to the Patient dimension on the Patient Key.  The users are looking for a distinct count of patients in all 4 fact tables.  
    What is the best way to accomplish this so that my cube does not talk all day to process?  Please let me know if you need any more information about my cube in order to answer this.
    Thanks for the help,
    Andy

    Hi Andy,
    Each distinct count measure cause an ORDER BY clause in the SELECT sent to the relational data source during processing. In SSAS 2005 or later, it creates a new measure group for each distinct count measure(it's a technique strategy for improving perormance).
    Besides, please take a look at the following distinct count optimization techniques:
    Create Customized Aggregations
    Define a Processing Plan
    Create Partitions of Equal Size
    Use Partitions Comprised of a Distinct Range of Integers
    Distribute the Hash of Your UserIDs
    Modulo Function
    Hash Function
    Choose a Partitioning Strategy
    For more detail information, please refer to the article below:
    Analysis Services Distinct Count Optimization:
    http://www.microsoft.com/en-us/download/details.aspx?id=891
    In addition, here is a good article about SSAS Best Practices for your reference:
    http://technet.microsoft.com/en-us/library/cc966525.aspx
    If you have any feedback on our support, please click
    here.
    Hope this helps.
    Elvis Long
    TechNet Community Support

  • Distinct count of role-played dimension attribute

    Needed distinct count of AccountGroup attribute of AccountB dimension which is a role played dimension of Account.
    Added measure distinct count of the dimension attribute (AccountGroup). In dimension usage added the main fact table as intermediate for other dimensions with many2many relationships.
    The two role played Account dimensions must be related to the new AccountFact table with fact relationship.
    But then how will I be able to count distinct attribute of
    certain Account dimension (out of the two role played dimensions)???
    Namnami

    Thanks for the links, they are useful. But still they do not explain how to manage a distinct count of
    certain role played dimension attribute. 
    I gave up on this and added that dimension attribute to the fact table so now I do a regular distinct count on a cube fact measure. 
    Thanks
    Namnami

  • 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

  • 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ões

    Hi 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

  • Distinct count using lookup table

    How can I get a distinct count of column values using a different table?
    Let's say I want to get a distinct count of all "company_name" records in table "emp" that corespond (match) with "lookup" table, "state" category.
    What I want is to find counts for all companies that have a value of "california" in the "state" column of the "lookup" Table. I want the output to look like:
    Sears 17
    Pennys 22
    Marshalls 6
    Macys 9
    I want the result to show me the company names dynamically as I don't know what they are, just that they are part of the "state" group in the lookup Table. Does this make sense?
    M

    Mark,
    In the future you might consider creating test cases for us to work with. Something similar to the following where sample data is created for each table as the union all of multiple select statementsselect 'INIT_ASSESS' lookup_type
         , 1 lookup_value
         , 'Initial Assessment' lookup_value_desc
      from dual union all
    select 'JOB_REF', 2, 'Job Reference' from dual union all
    select 'SPEC_STA', 3, 'SPEC STA' from dual;
    select 'INIT_ASSESS' rfs_category
         , 1 val
      from dual union all
    select 'JOB_REF', 1 from dual union all
    select 'JOB_REF', 1 from dual union all
    select 'SPEC_STA', null from dual;Then we can either take your select statements and make them the source of a CTAS (create table as) statementcreate table lookup as
    select 'INIT_ASSESS' lookup_type
         , 1 lookup_value
         , 'Initial Assessment' lookup_value_desc
      from dual union all
    select 'JOB_REF', 2, 'Job Reference' from dual union all
    select 'SPEC_STA', 3, 'SPEC STA' from dual;, or include them as subfactored queries by using the with statement:with lookup as (
    select 'INIT_ASSESS' lookup_type
         , 1 lookup_value
         , 'Initial Assessment' lookup_value_desc
      from dual union all
    select 'JOB_REF', 2, 'Job Reference' from dual union all
    select 'SPEC_STA', 3, 'SPEC STA' from dual
    ), RFS as (
    select 'INIT_ASSESS' rfs_category
         , 1 val
      from dual union all
    select 'JOB_REF', 1 from dual union all
    select 'JOB_REF', 1 from dual union all
    select 'SPEC_STA', null from dual
    select lookup_value_desc, count_all, count_val, dist_val
      from lookup
      join (select rfs_category
                 , count(*) count_all
                 , count(val) count_val
                 , count(distinct val) dist_val
              from RFS group by rfs_category)
        on rfs_category = lookup_type;Edited by: Sentinel on Nov 17, 2008 3:38 PM

  • Distinct Count doesn't return the expected results

    Hi All,
    I was fighting a little trying to implement a Distinct Count measure over an account dimension in my cube. I read a couple of posts relateed to that and I followed the steps posted by the experts.
    I could process the cube but the results I'm getting are not correct. The cube is returning a higher value compared to the correct one calculated directly from the fact table.
    Here are the details:
    Query of my fact table:
    select distinct cxd_account_id,
              contactable_email_flag,
              case when recency_date>current_date-365 then '0-12' else '13-24' end RECENCY_DATE_ROLLUP,
              1 QTY_ACCNT
    from cx_bi_reporting.cxd_contacts
    where cxd_account_id<>-1 and recency_date >current_date-730;
    I have the following dimensions:
         Account (with 3 different hierarchies)
         Contactable Email Flag (Just 3 values, Y, N, Unknown)
         Recency_date (Just dimension members)
    All dimensions are sparse and the cube is a compressed one. I defined "MAXIMUM" as aggregate for Contactable Email flag and Recency date and at the end, SUM over Account.
    I saw that there is a patch to fix an issue when different aggregation rules are implemented in a compressed cube and I asked the DBA folks to apply it. They told me that the patch cannot be applied because we have an advanced version already installed (Patch 11.2.0.1 ).
    These are the details of what we have installed:
          OLAP Analytic Workspace       11.2.0.3.0 VALID
          Oracle OLAP API 11.2.0.3.0 VALID
          OLAP Catalog 11.2.0.3.0 VALID
    Is there any other patch that needs to be applied to fix this issue? Or it's already included in the version we have installed (11.2.0.3.0)?
    Is there something wrong in the definition of my fact table and that's why I'm not getting the right results?
    Any help will be really appreciated!
    Thanks in advance,
    Martín

    Not sure I would have designed the dimensions /cubes as you,  but there is another method you can obtain distinct counts.
    Basically relies on using basic OLAP DML Expression language and can be put in a Calculated Measure, or can create two Calculated measures
    to contain each specific result.  I use this method to calculate distinct counts when I want to calculate averages, etc ...
    IF account_id ne -1 and (recency_date GT today-365) THEN -
    CONVERT(NUMLINES(UNIQUELINES(CHARLIST(Recency_date))) INTEGER)-
    ELSE IF account_id ne -1 and (recency_date GT today-730 and recency_date LE today-365) THEN -  
    CONVERT(NUMLINES(UNIQUELINES(CHARLIST(Recency_date))) INTEGER)-
    ELSE NA
    This exact code may not work in your case, but think you can get the gist of the process involved.
    This assumes the aggregation operators are set to the default (Sum), but may work with how you have them set.
    Regards,
    Michael Cooper

Maybe you are looking for