Forum Discussion

DanieleR's avatar
DanieleR
New Member
1 year ago
Solved

Help Needed with Power BI Data Modeling

Hello everyone,

I'm new to this forum and to Power BI and trying to understand how to properly model my data to analyze economic inequalities in a country. I have several datasets, and the structure is a bit unusual, so I'm not sure how to connect everything effectively.

Here are the tables I'm working with:

1. Salary Table

This table mixes salary data by job type and by age category, which is confusing. There is no age data in job-type rows and no job-type data in age rows:

Town_Code

Sexe

Job Type

Age in 3 category

Salary

abcde

Female

Executives

 

19.1

abcde

Female

Mid_Managers

 

13.2

abcde

Female

 

18to25

9.7

abcde

Male

 

50plus

18.6

(etc.)

    

2. Enterprise Table

Shows number of enterprises by size, per town:

Town_Code

Total_Enterprises

Enterprises_1_to_5

...

Enterprises_500_plus

abcde

996

272

...

0

3. Population Table

This one contains population by age group, sex, and cohabitation type:

Town_Code

Sexe

Age in 3 Category

Cohabitation Type (Code)

# Peoples

abcde

Male

15 to 25

11

340

abcde

Female

25 to 50

12

16

     

4. Geography Table

Contains the town names and geographic hierarchy (Region > Department > Commune, etc.)

My Objectives:

I'd like to analyze and compare:

  • Companies based on their location and size. 
  • Population based on salary and location. 
  • Focus on a big city.

My Questions:

  1. How should I model the Salary table? Since it mixes two different dimensions (Job Type and Age Category) in the same columns, I'm not sure how to split or normalize it.
  2. How can I structure the data into a star schema?
  3. How canI include the Cohabitation attribute in the model?
  4. What relationships should I create between these tables?
  5. Any general best practices for this kind of demographic/economic comparison?

I'm grateful for any guidance, schema suggestions, or resources you can share. I'm a beginner, so simple explanations are really appreciated!

Thanks in advance 🙏

  • Hi DanieleR , to overcome this, you need to do some modeling. 

     

    At first, let's rebuild SalaryData with these columns 

    Town_CodeGenderKeyCategoryKeySalary
    abcde2119.1
    abcde2213.2
    abcde249.7
    abcde1618.6

     

    Now, we need to create a bridge table that handles both job type and age group 

    DimCategory

    CategoryKeyCategoryTypeCategoryNameSortOrder
    1JobTypeExecutives1
    2JobTypeMid_Managers2
    3JobTypeEmployees3
    4AgeGroup18to2510
    5AgeGroup26to4911
    6AgeGroup50plus12


    We have location informations so create another table for that

    DimTown 

    Town_CodeTownNameDepartmentRegion
    abcdeParisParisĂŽle-de-France
    fghijLyonRhĂ´neAuvergne-RhĂ´ne
    klmnoMarseilleBouches-du-RhĂ´ne

    Provence-Alpes-CĂ´te

     

    and To get the gender Create another table 

    DimGender

    GenderKeyGender
    1Male
    2Female


    And, finally create this relationship with your other old tables 

    SalaryData → DimCategory (CategoryKey)
    SalaryData → DimTown (Town_Code)
    SalaryData → DimGender (Sexe)
    Population → DimTown (Town_Code)
    Enterprises → DimTown (Town_Code)

    Now, you have an organized model to answer your all queries. 

    If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!

6 Replies

  • The example tables you have provide are "reports" withj totals.

    They contaion no underlying details to build relationships.

     

    If you have access to underlying data then consider dumping it into one simple table with one record per person.

     

    • PersonID
    • Gender
    • Date Of Birth
    • Age (calculated column using DOB)
    • Enterprise / Company name|
    • Region
    • Town
    • Department
    • Commune

    Answers to youy questions:

     

  • Royel's avatar
    Royel
    Super User

    Hi DanieleR , to overcome this, you need to do some modeling. 

     

    At first, let's rebuild SalaryData with these columns 

    Town_CodeGenderKeyCategoryKeySalary
    abcde2119.1
    abcde2213.2
    abcde249.7
    abcde1618.6

     

    Now, we need to create a bridge table that handles both job type and age group 

    DimCategory

    CategoryKeyCategoryTypeCategoryNameSortOrder
    1JobTypeExecutives1
    2JobTypeMid_Managers2
    3JobTypeEmployees3
    4AgeGroup18to2510
    5AgeGroup26to4911
    6AgeGroup50plus12


    We have location informations so create another table for that

    DimTown 

    Town_CodeTownNameDepartmentRegion
    abcdeParisParisĂŽle-de-France
    fghijLyonRhĂ´neAuvergne-RhĂ´ne
    klmnoMarseilleBouches-du-RhĂ´ne

    Provence-Alpes-CĂ´te

     

    and To get the gender Create another table 

    DimGender

    GenderKeyGender
    1Male
    2Female


    And, finally create this relationship with your other old tables 

    SalaryData → DimCategory (CategoryKey)
    SalaryData → DimTown (Town_Code)
    SalaryData → DimGender (Sexe)
    Population → DimTown (Town_Code)
    Enterprises → DimTown (Town_Code)

    Now, you have an organized model to answer your all queries. 

    If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!

    • DanieleR's avatar
      DanieleR
      New Member

      Thank you! I think the solution you proposed is very clever and addresses my problem well. I just have one more question: would it make sense to apply the same approach you used for the Salary table to the Population table (because also in this case I have multiple variable combinations I'd like to keep in my data model), using a bridge table to connect and manage relationships?

  • v-nmadadi-msft's avatar
    v-nmadadi-msft
    Community Support

    Hi DanieleR 

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.


    Thank you.

  • Thanks for your help! Just to clarify: my dataset doesn't contain individual-level data : it's already aggregated. What I showed you, it was my data already partially modified. The original format includes several structured tables like the ones below:

    Population

    • "Town Code", "Town Name", "Cohabitation Type", "Age Category (5-year step)", "Sexe", "#People"

    Entreprise

    • "Town_Code", "Town_Name", "Region_Code", "Department_Code", "Total_Enterprises", "Enterprises_1_to_5", ... , "Enterprises_500_plus"

    Geo_Info

    • "Town_Code", ...

    Salary

    • "Town Code", "Town Name", "Avg_Net_Hourly_Salary", ..., "Avg_Net_Hourly_Salary_Workers", ..., "Avg_Net_Hourly_Salary_Employees_Female", ..., "Avg_Net_Hourly_Salary_50Plus", ..., "Avg_Net_Hourly_Salary_50Plus_Female"