Forum Discussion

DC2024's avatar
DC2024
Frequent Visitor
2 years ago
Solved

Struggling with creating correct data model - help please!

Hi all,

 

Sorry - I'm sure this is incredibly simple but I am struggling with the best way to set up my data model so that I can get proper insights. Hope the below makes sense, let me know if anything needs clarifying.

 

I have received a sample dataset from our Product team, attached (I've anonymised it as I can't share the original file). Basically it is a time series showing the inventory held for a number of household products held in each store. Each row is a single day's worth of data per store and product. Also on each row is the total inventory across the industry on that day for that product.

 

I've tried using something like the STAR method for constructing the data model (separating out the Dimensional data from the Fact data), but the visuals actually seemed to work better when I just left all the data in a single source and created charts / graphs over that single source.

 

I guess I just wanted to see how others (far more experienced than me!) would structure this in Power Query / use this data in Power BI to create better visuals, especially given the time series nature of the data. Sorry if this is a bit vague, am still very new to Power BI !

 

Thanks
DC

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi DC2024 ,

     

    You can create a separate dimension table for stores, products and date.

     

    For example:

     

    Fact Table:

     

    Product dimension table:

     

    Store dimension table:

     

    Date dimension table:

    DateTable = ADDCOLUMNS(
            CALENDAR(MIN('Fact Table'[Date]),MAX('Fact Table'[Date])),
            "Year",YEAR([Date]),
            "Quarter",ROUNDUP(MONTH([Date])/3,0),
            "Month",MONTH([Date]),
            "Day",DAY([Date])
    )

     

    Create relationships between them. This is key to a functional STAR schema. 

     

    pbix file is attached.

     

    If you have any further questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi DC2024 ,

     

    You can create a separate dimension table for stores, products and date.

     

    For example:

     

    Fact Table:

     

    Product dimension table:

     

    Store dimension table:

     

    Date dimension table:

    DateTable = ADDCOLUMNS(
            CALENDAR(MIN('Fact Table'[Date]),MAX('Fact Table'[Date])),
            "Year",YEAR([Date]),
            "Quarter",ROUNDUP(MONTH([Date])/3,0),
            "Month",MONTH([Date]),
            "Day",DAY([Date])
    )

     

    Create relationships between them. This is key to a functional STAR schema. 

     

    pbix file is attached.

     

    If you have any further questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    • DC2024's avatar
      DC2024
      Frequent Visitor

      That is fantastic, thank you very much Yang!

  • DC2024's avatar
    DC2024
    Frequent Visitor

    Sorry - doesnt seem to have let me attach the file! Here is a sample of the data:

    DateProduct IDProduct NameTotal Product Inventory (Industry)Store LocationInventory (Store)% Inventory Store vs. IndustryStore Inventory Id
    13/02/20247019466Bin5106000Leeds11530.0225816045167
    14/02/20247019466Bin5106000Leeds11530.0225816045167
    15/02/20247019466Bin5106000Leeds11530.0225816045167
    16/02/20247019466Bin5106000Leeds11530.0225816045167
    13/02/20247000211Hoover78560000London1800000022.9124236001065
    14/02/20247000211Hoover78560000London1800000022.9124236001065
    15/02/20247000211Hoover78560000London1800000022.9124236001065
    16/02/20247000211Hoover78560000London1800000022.9124236001065
    16/02/20247000486Duster2989454000Manchester16251860.0543636001910
    16/02/20247000486Duster2989454000Southampton20366030.0681266001911
    15/02/20247000486Duster2989454000Manchester16251860.0543636001910
    15/02/20247000486Duster2989454000Southampton20366030.0681266001911
    14/02/20247000486Duster2989454000Manchester16251860.0543636001910
    14/02/20247000486Duster2989454000Southampton20366030.0681266001911
    13/02/20247000486Duster2989454000Manchester16251860.0543636001910
    13/02/20247000486Duster2989454000Southampton20366030.0681266001911
    13/02/20247011835Sponge89483000Portsmouth1179890.1318566412733
    13/02/20247011835Sponge89483000Brighton10007911.1184146412734
    13/02/20247011835Sponge89483000Newcastle982490.1097966412735
    13/02/20247011835Sponge89483000London13128441.4671436412736