Forum Discussion

jswartz_09's avatar
jswartz_09
Helper I
6 months ago
Solved

Understanding Dimensional Modeling

Hi everyone, 

 

I'm beginning my journey on trying to create a dimensional model for our Power BI environment. I come from an SQL background in reporting of just writing SQL queries for the end user to share via an excel file, but finally we are working towards integrating Power BI as a BI tool for our division. 

 

However I am finding this to be a bit different than just simply writing an SQL query. 

 

I am learning that in Power BI you can't simply import the tables you have in SQL server and just join like you normally would in the Power BI Desktop modeling view and expect the same results. I'm finding that one to many relationships is the norm and they have to connect via the many side. Which is where I have come to this design of Dimensional Modeling. 

 

Most books or examples I find deal with sales or numerical data but we run a case management system so sometimes the examples don't always apply or are hard to replicate using our data. 

 

I'm really just looking for expert advice on how I should be taking something that I would normally write an SQL query for and create a dimensional model out of it, so that it can be used in Power BI. 

 

So getting down to an example: 

Lets say a requestor is asking me: For a List of cases that were completed in years 2024 and 2025 by region. The requestor would also like to know of those cases completed, what were the education information and employment information of each of the participants. 

 

I would simply write my SQL as the following:

 

select  a2.region, a1.pk_Participant_Id, a1.last_name, a1.first_name, a2.pk_Case_Id,  a3.completion_date, a3.completion_reason, a4.education_level, a5.employment_status
from participant a1
left join case a2
on a1.pk_Participant_Id = a2.fk_Participant_Id
left join completion a3
on a2.pk_Case_Id = a3.fk_Case_Id
left join education a4
on a1.pk_Participant_Id = a4.fk_Participant_Id
left join employment a5
on a1.pk_Participant_Id= a5.fk_Participant_Id 
where a3.completion_date between 2024-01-01 and 2025-12-31             

 

How would you go about creating a Dimensional model just using the tables from this query?
Participant Table Columns:

  • pk_Participant_Id
  • last_name
  • first_name
  • date_of_birth
    Case Table Columns: 
  • pk_Case_Id
  • fk_Participant_Id
  • region
  • created_date
    Completion Table Columns:
  • pk_completion_Id
  • fk_Case_Id
  • completion_date
  • completion_reason

Education Table Columns:

  • pk_Education_Id
  • fk_Participant_Id
  • education_level
  • created_date

Employment Table Columns:

  • pk_Employment_Id
  • fk_Participant_Id
  • employment_status
  • created_date

Appreciate any help you can all give me. 

  • v-achippa's avatar
    v-achippa
    6 months ago

    Hi jswartz_09,

     

    Here the error is happening because Education and Employment still have multiple rows per participant (1-* relationship). When you bring fields from all tables into a single visual, power bi cannot determine which Education or Employment record to use for each participant.

    • To make this work, you must first reduce Education and Employment to one row per participant, for example the latest record so the relationships become 1-to-1 with participant. Once those relationships become 1-to-1, the visual will work without errors.

     

    Thanks and regards,

    Anjan Kumar Chippa

14 Replies

  • jswartz_09 Would it be possible to provide sample data for these tables? That would make it much quicker to mock up and give you an answer.

    • jswartz_09's avatar
      jswartz_09
      Helper I

      Of course. 
      Here is the Participant Table: 

      pk_Participant_Idlast_namefirst_namedate_of_birth
      1JonesGeorge1/1/1955
      2BradshawTerry3/1/1975
      3SmithBob10/1/2001
      4DeppJohnny7/1/1990
      5DurhamBull2/1/1980
      6LincolnAbe11/15/1994
      7BassBilly12/2/1988
      8KhanShaka9/15/1964
      9StreisandBarb6/10/1989
      10ConnelyJennifer4/24/1990

       

       Case Table: 

      pk_Case_IDfk_Participant_Idregioncreated_date
      13North1/1/2023
      26South1/15/2023
      37East1/16/2023
      41West2/5/2023
      54North4/1/2023
      63North5/25/2023
      76South7/29/2023
      88West1/1/2024
      92West2/10/2024
      1010East4/10/2024
      115South5/1/2024
      129North7/25/2024
      135West8/1/2024
      148North9/20/2024
      151East11/15/2024
      167East1/2/2025
      172South1/15/2025
      183North5/11/2025
      1910North8/12/2025
      207West12/20/2025

       

      Completion Table: 

      pk_completion_idfk_case_idcompletion_datecompletion_reason
      113/27/2023Unsuccessful
      226/15/2023Unsuccessful
      348/5/2023Successful
      4510/1/2023Successful
      5712/1/2023Unsuccessful
      631/16/2024Successful
      765/25/2024Successful
      887/1/2024Unsuccessful
      9117/1/2024Unsuccessful
      1098/10/2024Successful
      111010/10/2024Successful
      12121/1/2025Successful
      13133/1/2025Successful
      14155/15/2025Unsuccessful
      15167/2/2025Successful
      16149/1/2025Successful
      171712/31/2025Successful

       

      Education Table:

      pk_Education_Idfk_participant_ideducation_levelcreated_date
      13High School1/1/2023
      26High School1/15/2023
      37Some College1/16/2023
      41Bachelors2/5/2023
      54High School4/1/2023
      68Some College1/1/2024
      72Bachelors2/10/2024
      810Doctorate4/10/2024
      95High School5/1/2024
      109Some College7/25/2024
      118Bachelors9/20/2024
      121Masters11/15/2024
      137Bachelors1/2/2025
      143Some College5/11/2025

       

      Employment Table:

      pk_Employment_Idfk_participant_idemployment_statuscreated_date
      13unemployed1/1/2023
      26part time1/15/2023
      37part time1/16/2023
      41full time2/5/2023
      54self employed4/1/2023
      66full time7/29/2023
      78full time1/1/2024
      82unemployed2/10/2024
      910full time4/10/2024
      105part time5/1/2024
      119unemployed7/25/2024
      127full time1/2/2025
      132full time1/15/2025
      143part time5/11/2025
      1510part time8/12/2025

       

      In case those are hard to read here is some photos: 

      Participant:

       

       

      Case:


      Completion: 

       

       

      Employment: 

       

       

      Education:

       

  • v-achippa's avatar
    v-achippa
    Community Support

    Hi jswartz_09,

     

    Thank you for reaching out to Microsoft Fabric Community.

     

    Thank you for the data. Based on the requirement here the Completion Table should be the fact table since the analysis is based on completed cases and completion date. Case and Participant Tables should be dimension tables. Education and Employment Tables must be reduced to one row per participant (latest record) before loading, otherwise power bi cannot determine which value to use.
    With this model, filtering completion date for 2024–2025 and grouping by region will return the same result as the sql query.

     

    Thanks and regards,

    Anjan Kumar Chippa

    • v-achippa's avatar
      v-achippa
      Community Support

      Hi jswartz_09,

       

      As we haven’t heard back from you, we wanted to kindly follow up to check if the solution I have provided for the issue worked? or let us know if you need any further assistance.

       

      Thanks and regards,

      Anjan Kumar Chippa

    • jswartz_09's avatar
      jswartz_09
      Helper I

      I need a little more information. How would the fact table look? What are the columns in the fact table? How would you model it with Dimensions?

      • v-achippa's avatar
        v-achippa
        Community Support

        Hi jswartz_09,

         

        Since your requirement is based on completed cases, the grain should be like one row per completed case. So the Completion table should be the fact table, by this we make sure that there is no duplication of cases.

        • The Case and Participant tables are dimension tables that describe that completed case.
        • The important part is Education and Employment. In sql, if a participant has multiple education or employment records, the query just duplicates rows. Power bi cannot do that cleanly because relationships need to return a single value, that is why education and employment need to be reduced to one row per participant like for example the latest record.

        So instead of flattening the data like sql, we create a clean fact table and connect the respective tables around it. With this model it gives the correct results.

         

        Thanks and regards,

        Anjan Kumar Chippa