Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi all I have the below calculation for fiscal week numbers, however it start the fiscal canlendar to start on the 1st April each year and I need it to start on the 1st Monday in April each year.
Can anyone suggest how to change this to get the right outcome?
Fiscal Week =
--Inputs--
VAR WeekStartsOn = "mon"
VAR FiscalStartMonth = 4
--Calculation--
VAR FiscalFirstDay =
IF(
MONTH('Date Table'[Date]) < FiscalStartMonth,
DATE(
YEAR('Date Table'[Date])-1,
FiscalStartMonth,
1
),
DATE(
YEAR('Date Table'[Date]),
FiscalStartMonth,
1
)
)
VAR FilteredTableCount =
COUNTROWS(
FILTER(
SELECTCOLUMNS(
GENERATESERIES(
FiscalFirstDay,
'Date Table'[Date]
),
"Dates",
[Value]
),
FORMAT([Dates],"ddd") = WeekStartsOn
)
)
VAR WeekNos =
IF(
FORMAT(FiscalFirstDay,"ddd") <> WeekStartsOn,
FilteredTableCount + 1,
FilteredTableCount
)
RETURN
"Week " & WeekNos
Hi @billyrich83
Try this, change the value in QUOTIENT to 2
Have you solved this question? If you have solved the question, you can accept the answer helpful as the solution or share you method and accept it as solution, thanks for your contribution to improve Power BI.
If you need more help, please let me know.
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hi @billyrich83 ,
I just modified a little in your code and it worked
Create a new column as below
Start of Week = ('Date'[Date]+-1*WEEKDAY('Date'[Date],2)) + 1
Modified the DAX that you shared as follows
FiscalWeek =
--Inputs--
VAR WeekStartsOn = "mon"
VAR FiscalStartMonth = 4
--Calculation--
VAR FiscalFirstDay =
IF(
MONTH('Date'[Date]) < FiscalStartMonth,
DATE(
YEAR('Date'[Date])-1,
FiscalStartMonth,
1
),
DATE(
YEAR('Date'[Date]),
FiscalStartMonth,
1
)
)
VAR FilteredTableCount =
COUNTROWS(
SELECTCOLUMNS(
GENERATESERIES(
FiscalFirstDay,
'Date'[Date]
),
"Dates",
[Value]
)
)
VAR WeekNos =
QUOTIENT(FilteredTableCount+1, 7)
RETURN
"Week " & WeekNos
Hi,
Thanks for this, 1 small issue it's showing the first dayte as zero and I'm now a day behind in the calculation is there a way to fix this? it might be something I've done.
When I checked the code, found that the hard coding that you have done works fine for one year (probably because you have hard coded based on that year) while it does not work for the other year. Have been busy since then. Hence unable to look into this further. May be someone else can get to help you with this.
@billyrich83 , Try these new columns
Start Of year = if(month([Date]) <4, date(year([Date])-1,4,1), date(year([Date])-1,4,1))
Start of Week = 'Date'[Date]+-1*WEEKDAY('Date'[Date]
FY Start of Week = minx(filter('Date', [Start of Week] >= [Start Of year]), [Start of Week])
FY Week No = quotient(datediff([FY Start of Week], [Date], day),7) +1
User | Count |
---|---|
128 | |
109 | |
100 | |
65 | |
62 |
User | Count |
---|---|
137 | |
115 | |
102 | |
71 | |
61 |