Forum Discussion
Monthly Targets split in Weeks
- 3 years ago
Hi , VKB
Based on your description, you want to divide the Target table into weeks by month. According to my understanding, there may be 4 or 5 weeks in a month, but for the first 4 weeks it is generally 7 days, and the fifth week is generally less than 7 days, so my understanding is to take the target/total number of days per month and then multiply the number of days per week to find the Target of the corresponding week.
Here are the steps you can refer to :
(1)We need to create a date table like this:Date = var _t = ADDCOLUMNS( CALENDAR( FIRSTDATE('Targets'[From Date]) ,LASTDATE('Targets'[To Date])), "Year" , YEAR([Date]),"Month",MONTH([Date]),"Month_Name",FORMAT([Date],"mmmm"),"Week","W"&ROUNDUP( DAY([Date])/7,0) ) var _t2 = ADDCOLUMNS(_t ,"Week_Days" , var _w = FILTER(_t ,[Year]=EARLIER([Year]) && [Month]=EARLIER([Month]) && [Week]=EARLIER([Week])) return COUNTROWS(_w)) return _t2(2)Then we need to create a measure :
Measure = var _cur_date = MAX('Date'[Date]) var _days_in_month = DAY(EOMONTH(_cur_date,0)) var _target =SUMX( FILTER( 'Targets' , YEAR('Targets'[From Date])= YEAR(_cur_date) && MONTH('Targets'[From Date])= MONTH(_cur_date)) , [ Target ]) var cur_week_days = MAX('Date'[Week_Days]) return DIVIDE(_target,_days_in_month) * cur_week_days(3)Then we can put the fields on the visual and we can meet your need:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi , VKB
Based on your description, you want to divide the Target table into weeks by month. According to my understanding, there may be 4 or 5 weeks in a month, but for the first 4 weeks it is generally 7 days, and the fifth week is generally less than 7 days, so my understanding is to take the target/total number of days per month and then multiply the number of days per week to find the Target of the corresponding week.
Here are the steps you can refer to :
(1)We need to create a date table like this:
Date = var _t = ADDCOLUMNS( CALENDAR( FIRSTDATE('Targets'[From Date]) ,LASTDATE('Targets'[To Date])),
"Year" , YEAR([Date]),"Month",MONTH([Date]),"Month_Name",FORMAT([Date],"mmmm"),"Week","W"&ROUNDUP( DAY([Date])/7,0) )
var _t2 = ADDCOLUMNS(_t ,"Week_Days" , var _w = FILTER(_t ,[Year]=EARLIER([Year]) && [Month]=EARLIER([Month]) && [Week]=EARLIER([Week])) return COUNTROWS(_w))
return
_t2
(2)Then we need to create a measure :
Measure =
var _cur_date = MAX('Date'[Date])
var _days_in_month = DAY(EOMONTH(_cur_date,0))
var _target =SUMX( FILTER( 'Targets' , YEAR('Targets'[From Date])= YEAR(_cur_date) && MONTH('Targets'[From Date])= MONTH(_cur_date)) , [ Target ])
var cur_week_days = MAX('Date'[Week_Days])
return
DIVIDE(_target,_days_in_month) * cur_week_days
(3)Then we can put the fields on the visual and we can meet your need:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- VKB3 years agoFrequent Visitor
Thank you very much. This solved my requirement.
- Anonymous3 years agoNot applicable
https://www.dropbox.com/scl/fi/czqfhn8fholrgavu9iy1a/Sample-Data.xlsx?dl=0&rlkey=3evm1cus93wij4pkux9jtmull
Can you help in this data?