Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hello,
Currently we have monthly targets, but I want to split them into daily ones to track results during the month.
I want them split based on proportion of each day of the week:
Monday - 18%
Tuesday - 18%
Wednesday - 16%
Thursday - 16%
Friday - 17%
Saturday - 8%
Sunday - 7%
Meaning that formula should evaluate how many different week days are in the month and divide monthly target accordingly.
Complication being that I have live connection to data model/analysis services and I cannot create tables. Just measures.
Maybe someone can help?
Thanks!
Solved! Go to Solution.
Hi @DANIPAR ,
Please try to adapt this logic to attend your need:
Daily Target =
VAR CurrentDate = MAX('Calendar'[Date]) -- Adjust to your date column
VAR MonthlyTarget = [Monthly Target] -- Replace with your actual measure for monthly target
VAR StartOfMonth = STARTOFMONTH('Calendar'[Date])
VAR EndOfMonth = ENDOFMONTH('Calendar'[Date])
-- Weekday counts in the current month
VAR Mondays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 1), 1)
VAR Tuesdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 2), 1)
VAR Wednesdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 3), 1)
VAR Thursdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 4), 1)
VAR Fridays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 5), 1)
VAR Saturdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 6), 1)
VAR Sundays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 7), 1)
-- Weekday proportions
VAR MondayTarget = 0.18 * MonthlyTarget / Mondays
VAR TuesdayTarget = 0.18 * MonthlyTarget / Tuesdays
VAR WednesdayTarget = 0.16 * MonthlyTarget / Wednesdays
VAR ThursdayTarget = 0.16 * MonthlyTarget / Thursdays
VAR FridayTarget = 0.17 * MonthlyTarget / Fridays
VAR SaturdayTarget = 0.08 * MonthlyTarget / Saturdays
VAR SundayTarget = 0.07 * MonthlyTarget / Sundays
-- Assign daily target based on the weekday
RETURN
SWITCH(
WEEKDAY(CurrentDate, 2),
1, MondayTarget,
2, TuesdayTarget,
3, WednesdayTarget,
4, ThursdayTarget,
5, FridayTarget,
6, SaturdayTarget,
7, SundayTarget
)
Hi @DANIPAR ,
In this case, just calculate the first day of the month using STARTOFMONTH('Calendar'[Date]), The MonthlyTarget variable is now calculated using CALCULATE([Monthly Target], 'Calendar'[Date] = FirstDayOfMonth), which ensures the target used is from the first day of the month, regardless of the current date in the report.
The rest of the logic remains the same as you can see bellow:
Daily Target =
VAR CurrentDate = MAX('Calendar'[Date]) -- Adjust to your date column
VAR FirstDayOfMonth = STARTOFMONTH('Calendar'[Date]) -- First day of the month
VAR MonthlyTarget = CALCULATE([Monthly Target], 'Calendar'[Date] = FirstDayOfMonth) -- Get monthly target from first day of the month
VAR StartOfMonth = FirstDayOfMonth
VAR EndOfMonth = ENDOFMONTH('Calendar'[Date])
-- Weekday counts in the current month
VAR Mondays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 1), 1)
VAR Tuesdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 2), 1)
VAR Wednesdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 3), 1)
VAR Thursdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 4), 1)
VAR Fridays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 5), 1)
VAR Saturdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 6), 1)
VAR Sundays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 7), 1)
-- Weekday proportions
VAR MondayTarget = 0.18 * MonthlyTarget / Mondays
VAR TuesdayTarget = 0.18 * MonthlyTarget / Tuesdays
VAR WednesdayTarget = 0.16 * MonthlyTarget / Wednesdays
VAR ThursdayTarget = 0.16 * MonthlyTarget / Thursdays
VAR FridayTarget = 0.17 * MonthlyTarget / Fridays
VAR SaturdayTarget = 0.08 * MonthlyTarget / Saturdays
VAR SundayTarget = 0.07 * MonthlyTarget / Sundays
-- Assign daily target based on the weekday
RETURN
SWITCH(
WEEKDAY(CurrentDate, 2),
1, MondayTarget,
2, TuesdayTarget,
3, WednesdayTarget,
4, ThursdayTarget,
5, FridayTarget,
6, SaturdayTarget,
7, SundayTarget
)
Hi @DANIPAR ,
To have get comulative quantity use this DAX:
MTD Running Target =
VAR CurrentDate = LASTDATE('Calendar'[Date])
RETURN
SUMX(
FILTER(
ALLSELECTED('Calendar'),
'Calendar'[Date] <= CurrentDate &&
'Calendar'[Date] >= STARTOFMONTH(CurrentDate)
),
[Quantity]
)
Hi @DANIPAR ,
Please try to adapt this logic to attend your need:
Daily Target =
VAR CurrentDate = MAX('Calendar'[Date]) -- Adjust to your date column
VAR MonthlyTarget = [Monthly Target] -- Replace with your actual measure for monthly target
VAR StartOfMonth = STARTOFMONTH('Calendar'[Date])
VAR EndOfMonth = ENDOFMONTH('Calendar'[Date])
-- Weekday counts in the current month
VAR Mondays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 1), 1)
VAR Tuesdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 2), 1)
VAR Wednesdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 3), 1)
VAR Thursdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 4), 1)
VAR Fridays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 5), 1)
VAR Saturdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 6), 1)
VAR Sundays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 7), 1)
-- Weekday proportions
VAR MondayTarget = 0.18 * MonthlyTarget / Mondays
VAR TuesdayTarget = 0.18 * MonthlyTarget / Tuesdays
VAR WednesdayTarget = 0.16 * MonthlyTarget / Wednesdays
VAR ThursdayTarget = 0.16 * MonthlyTarget / Thursdays
VAR FridayTarget = 0.17 * MonthlyTarget / Fridays
VAR SaturdayTarget = 0.08 * MonthlyTarget / Saturdays
VAR SundayTarget = 0.07 * MonthlyTarget / Sundays
-- Assign daily target based on the weekday
RETURN
SWITCH(
WEEKDAY(CurrentDate, 2),
1, MondayTarget,
2, TuesdayTarget,
3, WednesdayTarget,
4, ThursdayTarget,
5, FridayTarget,
6, SaturdayTarget,
7, SundayTarget
)
This works really well! Only thing being that it seems that targets in our data model are stored on the first day of the month... How your code can be adapted to overcome this?
Hi @DANIPAR ,
In this case, just calculate the first day of the month using STARTOFMONTH('Calendar'[Date]), The MonthlyTarget variable is now calculated using CALCULATE([Monthly Target], 'Calendar'[Date] = FirstDayOfMonth), which ensures the target used is from the first day of the month, regardless of the current date in the report.
The rest of the logic remains the same as you can see bellow:
Daily Target =
VAR CurrentDate = MAX('Calendar'[Date]) -- Adjust to your date column
VAR FirstDayOfMonth = STARTOFMONTH('Calendar'[Date]) -- First day of the month
VAR MonthlyTarget = CALCULATE([Monthly Target], 'Calendar'[Date] = FirstDayOfMonth) -- Get monthly target from first day of the month
VAR StartOfMonth = FirstDayOfMonth
VAR EndOfMonth = ENDOFMONTH('Calendar'[Date])
-- Weekday counts in the current month
VAR Mondays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 1), 1)
VAR Tuesdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 2), 1)
VAR Wednesdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 3), 1)
VAR Thursdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 4), 1)
VAR Fridays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 5), 1)
VAR Saturdays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 6), 1)
VAR Sundays = COUNTX(FILTER(ALL('Calendar'), 'Calendar'[Date] >= StartOfMonth && 'Calendar'[Date] <= EndOfMonth && WEEKDAY('Calendar'[Date], 2) = 7), 1)
-- Weekday proportions
VAR MondayTarget = 0.18 * MonthlyTarget / Mondays
VAR TuesdayTarget = 0.18 * MonthlyTarget / Tuesdays
VAR WednesdayTarget = 0.16 * MonthlyTarget / Wednesdays
VAR ThursdayTarget = 0.16 * MonthlyTarget / Thursdays
VAR FridayTarget = 0.17 * MonthlyTarget / Fridays
VAR SaturdayTarget = 0.08 * MonthlyTarget / Saturdays
VAR SundayTarget = 0.07 * MonthlyTarget / Sundays
-- Assign daily target based on the weekday
RETURN
SWITCH(
WEEKDAY(CurrentDate, 2),
1, MondayTarget,
2, TuesdayTarget,
3, WednesdayTarget,
4, ThursdayTarget,
5, FridayTarget,
6, SaturdayTarget,
7, SundayTarget
)
Hello @Bibiano_Geraldo , Now I'm trying to make month-do-date running SUM of those Daily targets. I used very simple formula for actual volumes (CALCULATE([Quantity],DATESMTD([Date])), but this doesn't work with those daily targets. Tried with SUM and SUMX, but just getting daily targets, but not month-do-date sum:
Hi @DANIPAR ,
To have get comulative quantity use this DAX:
MTD Running Target =
VAR CurrentDate = LASTDATE('Calendar'[Date])
RETURN
SUMX(
FILTER(
ALLSELECTED('Calendar'),
'Calendar'[Date] <= CurrentDate &&
'Calendar'[Date] >= STARTOFMONTH(CurrentDate)
),
[Quantity]
)
@DANIPAR
I did a webinar sometime back on this subject and covered many scenarios including this case on budget allocation. Please watch: https://youtu.be/E2MOnVEa99s
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@DANIPAR , Try using create a measure for the total number of each weekday in the current month:
DAX
WeekdayCount =
VAR CurrentMonth = MONTH(TODAY())
VAR CurrentYear = YEAR(TODAY())
VAR DaysInMonth = DAY(EOMONTH(TODAY(), 0))
VAR Weekdays =
ADDCOLUMNS(
CALENDAR(DATE(CurrentYear, CurrentMonth, 1), DATE(CurrentYear, CurrentMonth, DaysInMonth)),
"Weekday", WEEKDAY([Date], 2)
)
RETURN
SUMX(
Weekdays,
SWITCH(
TRUE(),
[Weekday] = 1, 1,
[Weekday] = 2, 1,
[Weekday] = 3, 1,
[Weekday] = 4, 1,
[Weekday] = 5, 1,
[Weekday] = 6, 1,
[Weekday] = 7, 1,
0
)
)
Create a measure for the daily target based on the weekday:
DailyTarget =
VAR MonthlyTarget = [YourMonthlyTargetMeasure]
VAR WeekdayPercent =
SWITCH(
TRUE(),
WEEKDAY(TODAY(), 2) = 1, 0.18,
WEEKDAY(TODAY(), 2) = 2, 0.18,
WEEKDAY(TODAY(), 2) = 3, 0.16,
WEEKDAY(TODAY(), 2) = 4, 0.16,
WEEKDAY(TODAY(), 2) = 5, 0.17,
WEEKDAY(TODAY(), 2) = 6, 0.08,
WEEKDAY(TODAY(), 2) = 7, 0.07
)
VAR TotalWeekdays = [WeekdayCount]
RETURN
MonthlyTarget * WeekdayPercent / TotalWeekdays
Use the DailyTarget measure in your visuals to track daily progress.
Proud to be a Super User! |
|
Check out the March 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
92 | |
66 | |
56 | |
46 | |
45 |