Forum Discussion

very_new_to_thi's avatar
very_new_to_thi
New Member
3 years ago

Trying to learn how to build a model - help requested

This is finance related. I have two tables for a business. One table is the budgetary table and the other is the transaction table. 

 

The budget is decided by several elements. As an example, the 'transportation' budget might be $500,000 but divided into four regions or six categories. 

 

The MISC Expenses budget might be $100,000 but split into several categories also. 

 

Here are example tables (incomplete):

Budget:

YearAccountStateDistrictFundTypeElementManagerBudgetQ1Q2Q3Q4
2023MainTXNorthD01FDave100002000200010001000
2023MainTXSouthD02GBrian150005000300000
2023MainFLNorthD01GBrian100000500050000
2023TransTXNorthD01FBrian500020001000500500
2023TransTXNorthD02FDave80002000500010000
2023TransTXSouthD01FDave50001500001500
2023Trans FLNorthD01GDave40001000100010001000
2023MiscTXNorthD02GDave200050050010000
2023MiscTXSouthD02GBrian30001000500500500
2023MiscFLSouthD02FBrian60000030002000

 

Transactions (incomplete):

YearAccountStateDistrictFundTypeElementManagerQuarterTransactionDescription
2023TransTXNorthD01FBrianQ1100........
2023TransTXNorthD01FBrianQ1150........
2023TransTXNorthD01FBrianQ2100........
2023Trans FLNorthD01GDaveQ250........
2023MainTXNorthD01FDaveQ150........
2023TransTXNorthD01FBrianQ1200........
2023Trans FLNorthD01GDaveQ1250........
2023TransTXNorthD01FBrianQ150........
2023MiscFLSouthD02FBrianQ2100........

 

There are several categorical elements [Account, State, District, FundType, Element, Manager] and then Quarter and Year for time-series. 

What I want to do is create a dimension table for the unique values. The problem I am having is if there are other transaction tables, then I would need to use inactive relationships with 'USERELATIONSHIP'. 

 

I would like to create tables that view per categories, sum the budget table and subtract the transactions from the total budget. 

 

Example:

DistrictBudetTransactionRemaining Budget
North$100000$43520$56480
South$85000$22500$62500


In order to do this, I would create a measure for the DistrictBudget that sums the budget for the district and adds that Measure to this table. But then i would need to repeat that for each categorical unit and I imagine there is a more efficient way. 

 

At the end, what I have to start is 2+ fact tables with many categorical columns to run analysis by. I have no standard dimension tables. 

 

The most important element is calculating the budget in a same table as the transactions to calculate the remaining budget and the time-series rate for which the budget is being spent. 

3 Replies

  • very_new_to_thi,

     

    Creating a star schema with fact and dimension tables is the preferred design. A dimension table should exist for each dimension (e.g., DimDistrict, DimFundType). You can create dimension tables in Power Query or DAX. Select distinct values for a dimension from both fact tables, and that table will become your dimension table. For example, select distinct District from each fact table, append those two tables, and select distinct District (this ensures that you have all possible District values across both fact tables). In the end, you will have multiple dimension tables, and each dimension table will have a one-to-many relationship with each fact table. You shouldn't need to create inactive relationships.

     

    The article below explains how to create a date table. I would add a date column to each fact table so you can create a relationship with DimDate. You can use the first day of the month (e.g., 2023 Q1 becomes 1/1/2023). The quarter columns in the Budget table need to be unpivoted so you have a single Quarter column.

     

    https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/ 

     

    Once the data model has been completed, create measures, and use dimension table fields in visuals.