Forum Discussion

j_w's avatar
j_w
Icon for Helper IV rankHelper IV
9 years ago
Solved

How to generate daily level data from monthly level data? - Post No. 2

There are two tables, a monthly Budget table (new  budget data will be added yearly, e.g. 2018-2019, 2019-2020 etc.): Year    MonthNo    User        MonthlyBudget 2017   7                   David  ...
  • TomMartens's avatar
    9 years ago

    Hmm,

    I'm not sure if I'm missing something, but hopefully this gets your started (here you can find a pbix file).

    There are the following steps:

     

    Step 1 - Data Preparation (The Query Section)

    First I prepared a simple Calendar table in the query section.

    This provides the possibility to Merge this table later on (to be precise a reference to this table called Budget Daily) with the Budget table. This Merge spreads the Budget table (User / Budget) across the appropriate days.

    This table contains the columns "Date", "MonthIso", and "Year".

     

    I created a colum "MonthIso" in the Budget table, this column is used for the Merge step.

     

    I referenced the table Calendar and renamed it to "Budget Daily" and removed the columns "Year" and "MonthIso".

     

    I merged the tables "Budget Daily"and "Budge". From the Budget table I'm just using the columns "User" and "Budget" from the table expansion step. I renamed the column "Budget" to "Budget Monthly".
    I skipped filtering the Rows without a "Budget".

    

    After doing this I close the query part and loaded the tables to the model

     

    Step 2 - Data Modeling (Creating Table Relationships and Columns)

     

    I created the following relationships

    Holiday <-> Calendar (One to One / Both)

    Budget Daily -> Calendar (Many to One / Single)

    Then I created the following columns in the Calendar table (using DAX)

    • WeekdayNo using the WEEKDAY() function to be able to differentiate between weekend and workdays, please be aware that subsequent steps are depending on the option you have chosen as 2nd parameter.
      I have chosen 2 (Weeks are starting on Monday), this means the IndexNo 6 and 7 are marking a weekend
    • IsWorkday
      Checking if the day is either a Saturday or a Sunday (0) or not (1)
    • IsHoliday (considering the Holiday table using RELATED())
      Checking if the Calendar day is in the Holiday, if this is the case, return 1 if not return 0
    • IsBudgetDay
      Checking if the Calendar day is
      • A workday and not a holiday return 1
      • All other cases return 0
    • BudgetDaysPerMonth
      Summing the column IsBudgetDay for each month returning the aggregated value to each day

    Finally I created a column in the "Budget Daily" table: Budget Daily

     

    Maybe this is a bit lenghty explanation, so please excuse if it does not help