Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
There is a Budget table:
Year MonthNo User MonthlyBudget BusinessDaysInMonth
2017 1 David 2200.00 22
2017 2 David 2000.00 20
... ...
2017 12 David 2100.00 21
2017 1 James 2200.00 22
2017 2 James 2000.00 20
... ...
2017 12 James 2100.00 21
How to generate another daily budget table in Power BI as following:
Date User DailyBudget Day
2017-01-01 David 0 Sunday
2017-01-02 David 100 Monday
2017-01-03 David 100 Tuesday
... ...
2017-12-28 David 100 Thursday
2017-12-29 David 100 Friday
2017-12-30 David 0 Saturday
2017-12-31 David 0 Sunday
2017-01-01 James 0 Sunday
2017-01-02 James 100 Monday
2017-01-03 James 100 Tuesday
... ...
2017-12-28 James 100 Thursday
2017-12-29 James 100 Friday
2017-12-30 James 0 Saturday
2017-12-31 James 0 Sunday
Thanks.
Solved! Go to Solution.
Hi @j_w,
First, we need a date table.
Date = ADDCOLUMNS ( CALENDAR ( DATE ( 2017, 1, 1 ), DATE ( 2017, 12, 31 ) ), "MonthNum", MONTH ( [Date] ) )
Second, we add a column "DailyBudget" in the table "Budget".
DailyBudget = 'Budget'[ MonthlyBudget] / 'Budget'[ BusinessDaysInMonth]
Third, we would get the result with this formula.
Result = SELECTCOLUMNS ( FILTER ( CROSSJOIN ( 'Date', 'Budget' ), 'Budget'[ MonthNo] = 'Date'[MonthNum] && YEAR ( 'Date'[Date] ) = 'Budget'[Year] ), "Date", [Date], "User", [User], "Day", FORMAT ( [Date], "dddd" ), "DailyBudget", IF ( WEEKDAY ( [Date], 2 ) IN { 6, 7 }, 0, [DailyBudget] ) )
Best Regards!
Dale
Hi @j_w,
First, we need a date table.
Date = ADDCOLUMNS ( CALENDAR ( DATE ( 2017, 1, 1 ), DATE ( 2017, 12, 31 ) ), "MonthNum", MONTH ( [Date] ) )
Second, we add a column "DailyBudget" in the table "Budget".
DailyBudget = 'Budget'[ MonthlyBudget] / 'Budget'[ BusinessDaysInMonth]
Third, we would get the result with this formula.
Result = SELECTCOLUMNS ( FILTER ( CROSSJOIN ( 'Date', 'Budget' ), 'Budget'[ MonthNo] = 'Date'[MonthNum] && YEAR ( 'Date'[Date] ) = 'Budget'[Year] ), "Date", [Date], "User", [User], "Day", FORMAT ( [Date], "dddd" ), "DailyBudget", IF ( WEEKDAY ( [Date], 2 ) IN { 6, 7 }, 0, [DailyBudget] ) )
Best Regards!
Dale
Thanks for your solution.
Could you have a look at another post?
Regards
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |