DAX CrossJoin between heavy facts

Dear Gurus,
I am using SSAS Tabular and creating SSRS reports on top of it. My datasets are pure DAX code, no MDX.
My issue is that I am unable to find out how to make my query fast when the dataset involves many facts.
Currently I am using the following query:
EVALUATE
ADDCOLUMNS(
FILTER(
SUMMARIZE(
CROSSJOIN(
FactFallRegistration,
FactPermissions
, Resident[Firstname]
, Resident[Lastname]
, Resident[NationalNumber]
, Room[RoomDescription]
, Room[RoomTypeEN]
, CareProfile[CareProfileCode]
), --Summarize
FactPermissions[# Active Permissions] > 0
)--Filter
, "ResidentFirstname", Resident[Firstname]
, "ResidentLastName", Resident[Lastname]
, "ResidentNationalNumber", Resident[NationalNumber]
, "ResidentRoomDescription", Room[RoomDescription]
, "ResidentRoomTypeEN", Room[RoomTypeEN]
, "RizivCareProfile", CareProfile[CareProfileCode]
, "# Falls", FactFallRegistration[# Falls]
)--ADDCOLUMNS
The following model represents my cube:
The starting point is the Fact Falls, all attributes I need to read are linked to the factFalls except DimCareProfile, and in order to get a care profile a measure called
# Active Permissions must be positive for one resident on one day.
Currently I am using a plain crossjoin embedded in a Filter that excludes the null/0 permissions; factPermissions is significant in term of size, hence the query as-is (without SSRS filters) takes 2:30minutes to execute.
How can I tune this query to propagate the context from falls to the careprofile without a crossjoin ?
What is the querying best practice when multiple facts are to be used in the same query (2 facts or more)?
Thanks so much for any insights
Miloud

Marco thanks for the tip !
But I am a bit surprised because the query still takes a very long time :-/
I don't get it, if I am at a certain row in Fact Fall, if then I want to get the CareProfile, going through the Fact Permissions should be ultra fast since the link (Resident + Date) is known...
Or is my query construct non accurate ?
Marco moreover, let's imagine the starting point is Fact Falls, how could you still get the value of the CareProfile ? I have troubles to understand how can I navigate from Fact Falls to RizivCareProfile
 Edit:
I made some progress, now I have a super fast query. The idea i followed is as below:
EVALUATE
CALCULATETABLE(
FILTER(
ADDCOLUMNS(
SUMMARIZE(
GENERATE(
Filter(
FactFallRegistration,
[# Falls Permitted Long Stay] = 1
, CareProfile
, Resident[Firstname]
, Resident[Lastname]
, Resident[NationalNumber]
, OperationalUnit[OperationalUnitNumber]
, 'Date'[BK_Calendar] , CareProfile[CareProfileCode]
, "CareProfile", CareProfile[CareProfileCode]
) -- summarize
, "# Falls", [# Falls Permitted Long Stay]
,[# Falls Permitted Long Stay] > 0
, Resident[NationalNumber] = "XXX"
ORDER BY
'Date'[BK_Calendar]
I embedded the many to many relationship in a measure to have a cleaner approach.
Now this data set gives me something like:
Now what I am unable to achieve is to get something like:
Indeed, I need to group on resident operational unit...etc then give the total number of falls and the last value of CareProfile (in the 1st table above it's C)
I tried using the LastNonBlank but no luck, how can I do a sort of tail or whatever DAX oriented call to get the last version of the careprofile ?
Thanks very much

Similar Messages

  • Bridge Table between two fact tables

    Hello everybody,
    From what I have read on the BI Administration tool help and on this forum, bridge tables are used to define many-to-many relations between dimension sand fact tables. Is it possible to have a bridge table defining a many-to-many relation between two fact tables?
    Here is my senario:
    1. We have a fact table called fact_Orders describing orders for some products.
    2. We have a fact table called fact_Sales describing sales og these products.
    3. We have a table describing the transformation from order lines to sales lines which is a many-to-many relation, because it is possible to transform an order in more than two steps.
    I was thinking of connecting the two fact tables with a bridge table.
    If bridge tables are inappropriate for this case, what could be a better model for my senario?
    Thanks for your time.

    Hi,
    Well a conformed dimension is a bridge table between two facts, so not sure why you need anything else. If there is a one to many from D1 to F1 and a one to many from D1 to F2 then effectively there is a many to many join from F1 to F2 through the D1 dimension.
    Sounds to me like all you need is an order dimension table, rows in the orders fact table will join to this dimension and so will rows in the sales fact table. You can then do calculations like number of sales per order, total sales revenue per order, # of order items per order etc etc.
    Regards,
    Matt

  • Multiple 'logical joins' between a fact table and one dimension table

    It appears that one cannot create multiple ‘logical joins’ between a fact table and one dimension table in OBIEE using the Oracle BI Administration Tool. For example, considering a Business Model with a dimension table TIMES and a fact table FACT containing START_TIME and END_TIME, we would like to create separate logical joins from FACT to TIMES for the START_TIMEs and END_TIMEs? Obviously, the underlying foreign keys can be created, but as far as I can tell the Oracle BI Administration Tool doesn’t support this. The workaround would be to replicate the TIMES table, but that’s ugly.
    I seek an alternative approach.

    Try this. Create an two aliases for the TIMES dimension (Start & End) in the Physical Layer and then remove foreign key to the "Parent" Times dimension. Create the Foreign Key in the Physical Layer to the new aliases and then create the complex joins in the BMM Layer to the new aliases as well. This will allow you to present both dates within the same table in the Presentation Layer. Not the most elegant solution but it works.

  • Connection between two fact tables.

    I have a problem in OBIEE 10.1.3.2:
    I have two fact tables A and B. Both tables have three columns - time_id, position_id and valuea (table A), time_id, position_id and valueb (table B). I have dimensions TIME (id, time) and POSITION (id, post). Facts A and B are connected to dimensions and
    both queries
    select TIME.time, POSITION.post, A.valuea,
    select TIME.time, POSITION.post, B.valueb
    work properly.
    But it is definitely impossible to execute query
    select TIME.time, POSITION.post, A.valueA, B.valueB.
    [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 15018] Incorrectly defined logical table source (for fact table A) does not contain mapping for [B.VALUEB]. (HY000)
    Another two fact tables in the same application I can join in any query wihout any problem.
    How is it possible?
    Thanks for your help
    Jiri

    How did you joined two Fact tables. Did you use Dimension table between?

  • Connection between 2 fact tables

    Hello guys!
    Suppose the following situation (it's a simplified one, of course):
    1) I have a dimension table d_contract with a list of contracts (and some attributes of a contract like its term and type). The primary key is ID_CONTRACT
    2) I have a fact table f_payments which contains payments for all contracts. It contains fields: ID_CONTRACT, AMOUNT_PAYMENT, DATE_OF_PAYMENT, ID_SALESROOM (so a measure is AMOUNT_PAYMENT: its default aggregation rule is set to SUM). Each contract can have many payments in different salesrooms.
    3) I have a dimension table d_salesroom with a list of all salesrooms (and some attributes of a salesroom like its address) where payments can be installed. The primary key is ID_SALESROOM
    4) I have a fact table f_calls which contains all phone calls (in tech support) regarding contracts. It contains fields: ID_CONTRACT, DATE_OF_CALL, DURATION_OF_CALL (so a measure is DURATION_OF_CALL: its default aggregation rule is set to SUM). Many calls for each contract can be done.
    Those were physical tables, and logical tables are the same. Connections between tables (physical and logical) are quite obvious: f_payments is connected with d_salesroom and d_contract, f_calls is connected with d_contract only.
    Then I want to run the following request (in Answers):
    ID_SALESROOM | ID_CONTRACT | SUM(AMOUNT_PAYMENT) | SUM(DURATION_OF_CALL)
    That is: for all salesroom I want to see all contracts (which were paid in the salesroom) and for each contract I want to see sum of payments (in the salesroom) and duration of all calls for that contract (not regarding the salesroom). If a contract was paid in more than one salesroom then the duration of calls should be the same for all salesrooms - duration is connected only to a contract, not to a salesroom.
    If I write this request in answres, I get zero call duration for all contracts. And in request log I see an expression CAST(NULL as INTEGER) instead of SUM(DURATION_OF_CALL). I suspect this is because d_salesroom isn't in any way connected with f_calls (neither physically nor logically). But what to do if I want a query like the above one to run correctly?
    What can I do with the repository to perform queries like that?

    Hi AFSK,
    d_contract is common dimension b/w two facts so in f_cells LTS add d_contract and f_payments into single source
    then your query will generated in the following way
    select a.Id_salesroom,b.Id_contract,c.Sum(Amount_payment) ,d.Sum(Duration_of_call) from
    d_salesroom a,d_contract b,f_cells c,f_payments d
    where a.Id_SalesRoom=d.Id_SalesRoom and a. Id_Contract=d.Id_Contract and a.Id_Contract=c.Id_Contract
    group by a.Id_salesroom,b.Id_contract
    hope it helps you

  • Relationship between two facts

    I have 2 fact tables (Encounter and Visit) which have an optional 1 to many relationship.  For a query the users are trying to run, they are using DepartmentDim, which is related to both facts, and AppointmentStatusDim, which is related ONLY to VisitFact.
     They want to see a count of encounters by department and appointment status.  The problem is when they pull in the count from the Encounter measure group, it is showing the same count for all of the values in each row.  
    How do I need to create the relationship between the two fact tables so that I can use dimensions that are related to only one fact table but pull in a measure from the other fact?
    Any help is appreciated.
    Thanks,
    Andy

    Sounds like you need a bridge table to complete the M2M relationship...
    FactVisit
      DepartmentKey
      AppointmentStatusKey
      EncounterGroupKey
    FactEncounter
      DepartmentKey
      EncounterGroupKey
    BridgeVisitEncounter
      EncounterGroupKey
    DimAppointmentStatus <-- FactVisit --> BridgeVisitEncounter <-- FactEncounter 
    This will allow you to slice measures in the FactEncounter measure group by attributes in the DimAppointmentStatus dimension...
    BI Developer and lover of data (Blog |
    Twitter)

  • How to pass variable between CRM Fact sheet and BI web template

    Hello,
    I am looking for someone who has integrated a custom web template with the CRM fact sheet (I am on 2004s).
    I have created a custom web application design template for displaying on the portal for a CRM factsheet (TPL_FACT_SHEET).
    This template is based on a query which has a variable (CHOOSE_CUST, ready for input, input: optional type) on 0CUSTOMER char.
    When the sales rep queries the CRM FactSheet on the portal- based on the 0CUSTOMER he is demanding the fact sheet for,  the appropriate 0CUSTOMER value needs to be parsed to my custom web template and it should return him the report. The report is very simple with just sales for current and previous year by material group. There is a std template to do this but we are using cutom data providers and hence need to create this custom web template.
    Thus far I have created a 'filter pane' in my web template but do not know how to link this with the CRM fact sheet or even how to link it to my query variable. Currently when my template is called from the factsheet (portal) it displays results for multiple customers without any filter!
    Please advise how to proceed in linking the CRM fact sheet 0Customer number with my web template filter pane!
    Full points for useful answers!
    Thanks
    Naresh

    Hello,
    I am looking for someone who has integrated a custom web template with the CRM fact sheet (I am on 2004s).
    I have created a custom web application design template for displaying on the portal for a CRM factsheet (TPL_FACT_SHEET).
    This template is based on a query which has a variable (CHOOSE_CUST, ready for input, input: optional type) on 0CUSTOMER char.
    When the sales rep queries the CRM FactSheet on the portal- based on the 0CUSTOMER he is demanding the fact sheet for,  the appropriate 0CUSTOMER value needs to be parsed to my custom web template and it should return him the report. The report is very simple with just sales for current and previous year by material group. There is a std template to do this but we are using cutom data providers and hence need to create this custom web template.
    Thus far I have created a 'filter pane' in my web template but do not know how to link this with the CRM fact sheet or even how to link it to my query variable. Currently when my template is called from the factsheet (portal) it displays results for multiple customers without any filter!
    Please advise how to proceed in linking the CRM fact sheet 0Customer number with my web template filter pane!
    Full points for useful answers!
    Thanks
    Naresh

  • SSAS 2008 Linking two cubes on the foreign key between two fact tables

    Hi, all -- 
    I have two cubes:
    Cube 1 has Fact1 (F1, "Events") and 3 dimensions (D1, D2, D3)
    Cube 2 has Fact2 (F2, "Sales") and 3 dimensions (D4, D1, D6)
    As you can see, two cubes reuse D1 as their common dimension.  In addition, F2 foreign keys into F1, e.g. F1 is "Events", and F2 is "Sales".  Every "sale" is an "event", but not every "event" is
    a "sale".
    The question is, how to I link the two cubes and their two respective fact tables on the foreign key?
    Thanks, Austin.

    Hi Austin,
    According to your description, you want to retrieve data from two different cubes, right? In Analysis Services, to query multiple cubes from a single MDX statement you can use the LOOKUPCUBE function (you can't specify multiple cubes in your FROM statement).
    The LOOKUPCUBE function will only work on cubes that utilize the same source database as the cube on which the MDX statement is running. For the detail information about it, please refer to the link below to see the blog.
    Retrieving Data From Multiple Cubes in an MDX Query Using the Lookupcube Function
    If I have anything misunderstood, please point it out.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Join Between Dimension & Fact Table

    Hi all,
    Here is my scenerio:
    There are two tables, one dimension table and one fact table.
    Normally, they will be joined with a key, says Date_ID.
    However, these two tables do not have the same key.
    Question comes, can I create derived columns in both tables to pretend as key (the value of key assumes the same) and join them together? If yes, which layer (physical or business logic) to do the join? Will data be shown in Answer correctly?
    Thanks.

    Thanks for reply.
    I know that if two tables have the same key, says primary key and foreign key, they can be joined directly.
    However, the tables do not have the same key/column for join.
    Actually, I've tried to create dummy columns in both tables to join together in physical layer. Then use those dummy columns in business model layer to get the value from other columns. Complex join is carried out later in business moel layer. But it seems that it does work.

  • Forcing full outer join between two facts according to common dimensions

    Hi everyone,I have an issue with the way obiee "joins" 2 fact tables regarding according to common dimensions.
    Let's assume 2 fact tables F1 and F2 and 2 dimension D1 and D2.
    Fi is joined to Dj thanks to IDs.
    F1 and F2 have got aggregates sum(mes1), respectively sum(mes2).
    The group by is performed on dim1 for D1 and dim2 for D2.
    The following 2 queries work fine...but separately:
    select dim1, dim2, sum(mes1) from F1, D1, D2 where ... group by dim1, dim2; //7 lines
    select dim1, dim2, sum(mes2) from F2, D1, D2 where ... group by dim1, dim2; //8 lines
    When I try to select dim1, dim2, sum(mes1) and sum(mes2), the following sql is created by the BI server:
    WITH SAWITH0 AS (
    select dim1, dim2, sum(mes1) c3 from F1, D1, D2 where ... group by dim1, dim2
    ), SAWITH1 AS (
    select dim1, dim2, sum(mes2) c3 from F2, D1, D2 where ... group by dim1, dim2
    select ... dim1,
         ... dim2,
         ... SAWITH0.c3,
         ... SAWITH1.c3
    FROM SAWITH0 LEFT OUTER JOIN SAWITH1
         on SAWITH0.dim1=SAWITH1.dim1 and SAWITH0.dim2=SAWITH1.dim2
    I get only 7 lines. It means I miss one line from the second query on F2.
    The solution is to perform a full outer join. (I tried in TOAD and changing LEFT by FULL is ok)
    How can I force the full outer join?
    Thanks a lot!

    If you use the fact vertical capabilities of OBIEE, it will normally perform a full outer join :
    http://gerardnico.com/wiki/dat/obiee/logical_sql/obiee_full_outer_join
    Check here for an example (replace the fact cross join by your second fact table F2)
    http://gerardnico.com/wiki/dat/obiee/bi_server/design/obiee_densification_design_preservation_dimension
    Cheers
    Nico

  • Prompt Constrain between two facts

    Hello All,
    I have two facts at different granular levels.
    My prompt uses some conformed dimensions and some non conformed.
    also in my prompt I have
    my measure columns as edit boxes as the user want to give filters like >=100 etc.
    Now I want to constrain my prompts.
    I have a promt from a conformed dimension, I want it to show all the values i.e,
    dimension values for fact 1
    and dimension values for fact 2.
    so basically somethin like
    union of all the values.
    But it also needs to constrain to other prompts
    Is there a way I can acheive this?
    Thanks,
    Deep

    Hi All,
    If any one has achieved this functionality, pls share with me.
    while going through some posts have come across mdx queries, does this help in resolving my problem?

  • Bridge table between fact/dim table

    My requirement is to create a relationship between fact (service request) and dim (timesheet) table.
    Many rows of dim table is related to a record in Service request. Hence i created a bridge table to join them.
    I imported the bridge table into physical layer. Then created two foreign key between the bridge table, dim/fact tables.
    Then pulled the bridge table into the dimension logical table source. Then created a new logical join between the fact and dimension table.
    When i want to count the nbr of service request, my query is not hitting the service request fact.
    Is there any step missed to create the relationship between the fact and dimension for introduction bridge table.
    Pls any one provide the step by step for this process. This is little urgent.
    Thanks

    Just continue on Marks blog...he put it all together nicely:
    http://www.rittmanmead.com/2007/06/19/obiee-data-modeling-tips-1-integrating-1-1-and-1-many-source-tables/
    and
    http://www.rittmanmead.com/2007/09/16/obiee-dimension-data-modeling-redux/
    Cheers,
    C.

  • Fact vertical capabilities - Full outer Join - How to?

    Hi,
    I have the same problem described in another post: Forcing full outer join between two facts according to common dimensions
    I will use the same example:
    Let's assume 2 fact tables F1 and F2 and 2 dimension D1 and D2.
    Fi is joined to Dj thanks to IDs.
    F1 and F2 have got aggregates sum(mes1), respectively sum(mes2).
    The group by is performed on dim1 for D1 and dim2 for D2.
    The following 2 queries work fine...but separately:
    select dim1, dim2, sum(mes1) from F1, D1, D2 where ... group by dim1, dim2; //7 lines
    select dim1, dim2, sum(mes2) from F2, D1, D2 where ... group by dim1, dim2; //8 lines
    When I try to select dim1, dim2, sum(mes1) and sum(mes2), the following sql is created by the BI server:
    WITH SAWITH0 AS (
    select dim1, dim2, sum(mes1) c3 from F1, D1, D2 where ... group by dim1, dim2
    ), SAWITH1 AS (
    select dim1, dim2, sum(mes2) c3 from F2, D1, D2 where ... group by dim1, dim2
    select ... dim1,
    ... dim2,
    ... SAWITH0.c3,
    ... SAWITH1.c3
    FROM SAWITH0 LEFT OUTER JOIN SAWITH1
    on SAWITH0.dim1=SAWITH1.dim1 and SAWITH0.dim2=SAWITH1.dim2
    I get only 7 lines. It means I miss one line from the second query on F2.
    The solution is to perform a full outer join between both queries..
    The reply was a link to fact vertical capabilities of OBIEE
    (http://gerardnico.com/wiki/dat/obiee/logical_sql/obiee_full_outer_join)
    (http://gerardnico.com/wiki/dat/obiee/bi_server/design/obiee_densification_design_preservation_dimension)
    In this post the solution is to add a dummy fact table to force a crossjoin.
    This solution don't work in my case because I don't need to return all the members of the dimension, I just need to return the dimension member that are joined to both facts..
    if in the example, the dimension have 20 member with the fact vertical capabilities solution my reports will show 20 rows... and I only want to see 8 rows...
    Any Idea?
    Thanks...

    I found what was the real problem:
    I have two diferent physical and logical Facts with 4 common dimensions and 1 dimesion that only affect to the second fact.
    In my report I'm filtering for this last dimension so the OBI use this query (the more restrictive) and made a left join with the second result...
    The problem is what I need is filter only by the column, but I cant do it because I'm using a column selector and I can't do a FILTER USING statement using a dashboard prompt...
    Any Idea?
    Thanks

  • DAX Tabular model - Question regarding filtering twice

    We have a Fact table with two data sources. Now I have a DAX measure to filter out to one data source
    Chat Handled := CALCULATE( SUM([Handled]),DimDataSource[SourceOrType] = "Chat Source 1")
    I have other Fact tables where we have other data sources - which are defined in the DimDataSource. So basically when we try to conform across all Facts with DataSources, other Facts are looking good - expect this Chat Fact where it shows the same numbers
    again.  Below is the view when I slice the data using a pivot -
    Is there a way to fix this (mainly for chat handled) above  or is there any work around for this ? Appreciate your help with this.
    Row Labels
    Incidents
    Chat Handled
    Surveys
    Phone calls
    Incidents  Source 1
    123,456
    12,345,678
    Survey  Source 1
    12,345,678
    123,456
    Incidents  Source 2
    12,345,678
    12,345,678
    Survey  Source 2
    12,345,678
    234,567
    Survey  Source 3
    12,345,678
    345,678
    Survey  Source 4
    12,345,678
    456,789
    Phone  Source 1
    12,345,678
    1,234,576
    Phone  Source 1
    12,345,678
    2,345,678
    Chat  Source 1
    12,345,678
    Chat  Source 2
    12,345,678

    The only thing I can think of with the information you gave is that there is something wrong with the relationship between the Fact and your Dim.
    Is the relationship defined in the data model ? (it seems to me that filtering the Dim does not propagate to the Fact)
    Driezl

  • Not getting desired fact measures in answers

    Hello, In my schema I have 2 fact tables and 5 Dimension tables. In a particular case, I have two fact tables F1 and F2 and a Dimension D1.
    The relationship is like this D1 -< F1>- F2. That is there exist a relationship between the fact tables.
    In my repository I have D1-<F1 and D1-<F2
    Now, in Answers, when I am selecting a column from D1 and a measure column from F1 and F2 both; I am getting blank results and only values for Dimension Column are shown. When I remove one of the Fact columns I can see the values from Dimension and Fact measures and vice-versa.
    Any idea why this is happening and how can I correct it?
    Thank you for your time!

    Ashish,
    This scenario has been discussed so widely resulting with no widely accepted solution.
    Note: Bmm layer is not good at supporting joins between multi-star schemas - in other words between multi fact tables, apart from summary or aggregate tables. Whenever a query involving a non-conformed dimension is fired, the fact table that doesn't have a direct raltionship with the dimension is treated as null.
    Thus to overcome such kind of scenarios here are 2 solutions I recommend:
    1. To eliminate nulls in f2 column when f1,f2& d1 are queried associate f2 measures with grand total level of d1. <-- It is associated with only a grand total level just becasue it does not in anyway refer to dimension d1, when compared to other levels which have keys associated with dimension. (I assume this as a quirk in OBIEE).
    2. Create an logical table source alias (by dragging f2 onto sources folder) and within this logical source join f1 to d2 and d2 to f2 (hope now you understand, we are joining them through a conformed dimension). Thus whenever a query invloving f1,f2,d1 is fired is routed through this source. <-- You might ask why i need to route only through d2? well it is a conflicting scenario and is left upto the developers.
    mark as answered if helpful& let me know if you have further questions.
    P.S Also i think i did publish a post on this on my blog...
    -bifacts :-)
    http://www.obinotes.com
    Edited by: bifacts on Nov 3, 2010 11:26 PM

Maybe you are looking for