The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello everyone! I tried to create an academic date calendar with the WEEKNUM(DATE, 21) function and that works for the calendar year. However, I need the first week to begin on these dates in August that are not separated by the same period of time:
(8/22/2022; 8/23/2021; 8/24/2020; 8/26/2019; 8/27/2018; 8/28/2017; 8/22/2016; 8/24/2015; 8/25/2014; 8/26/2013; 8/27/2012).
Can anyone please help?
Solved! Go to Solution.
Hi @dhall001,
You may try this solution.
Here is the sample data created from a DAX formula.
Table = CALENDAR(DATE(2019,1,1),DATE(2022,12,31))
Create a Calculated column to identify Academic Year.
First Day Of Fiscal Year =
SWITCH (
TRUE (),
'Table'[Date] >= DATE ( 2022, 8, 22 ), DATE ( 2022, 8, 22 ),
'Table'[Date] >= DATE ( 2021, 8, 23 )
&& 'Table'[Date] < DATE ( 2022, 8, 22 ), DATE ( 2021, 8, 23 ),
'Table'[Date] >= DATE ( 2020, 8, 24 )
&& 'Table'[Date] < DATE ( 2021, 8, 23 ), DATE ( 2020, 8, 24 ),
'Table'[Date] >= DATE ( 2019, 8, 26 )
&& 'Table'[Date] < DATE ( 2020, 8, 24 ), DATE ( 2019, 8, 26 ),
'Table'[Date] >= DATE ( 2018, 8, 27 )
&& DATE ( 2019, 8, 26 ), DATE ( 2018, 8, 27 )
)
Create another Calculated column to get Fiscal Weeks.
Fiscal Weeks =
var FilteredTableCount=COUNTROWS(
FILTER(
SELECTCOLUMNS(
GENERATESERIES(
'Table'[First Day Of Fiscal Year],
'Table'[Date]
),
"Dates",
[Value]
),
FORMAT([Dates],"ddd")="Thu" //mark the first thursday of the first week as week 1
)
)
VAR WeekNos =
IF(
FORMAT('Table'[Date],"ddd") <> "Thu",
FilteredTableCount + 1,
FilteredTableCount
)
return WeekNos
The result looks like this.
Also, attached the pbix file as reference.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Hi @dhall001,
You may try this solution.
Here is the sample data created from a DAX formula.
Table = CALENDAR(DATE(2019,1,1),DATE(2022,12,31))
Create a Calculated column to identify Academic Year.
First Day Of Fiscal Year =
SWITCH (
TRUE (),
'Table'[Date] >= DATE ( 2022, 8, 22 ), DATE ( 2022, 8, 22 ),
'Table'[Date] >= DATE ( 2021, 8, 23 )
&& 'Table'[Date] < DATE ( 2022, 8, 22 ), DATE ( 2021, 8, 23 ),
'Table'[Date] >= DATE ( 2020, 8, 24 )
&& 'Table'[Date] < DATE ( 2021, 8, 23 ), DATE ( 2020, 8, 24 ),
'Table'[Date] >= DATE ( 2019, 8, 26 )
&& 'Table'[Date] < DATE ( 2020, 8, 24 ), DATE ( 2019, 8, 26 ),
'Table'[Date] >= DATE ( 2018, 8, 27 )
&& DATE ( 2019, 8, 26 ), DATE ( 2018, 8, 27 )
)
Create another Calculated column to get Fiscal Weeks.
Fiscal Weeks =
var FilteredTableCount=COUNTROWS(
FILTER(
SELECTCOLUMNS(
GENERATESERIES(
'Table'[First Day Of Fiscal Year],
'Table'[Date]
),
"Dates",
[Value]
),
FORMAT([Dates],"ddd")="Thu" //mark the first thursday of the first week as week 1
)
)
VAR WeekNos =
IF(
FORMAT('Table'[Date],"ddd") <> "Thu",
FilteredTableCount + 1,
FilteredTableCount
)
return WeekNos
The result looks like this.
Also, attached the pbix file as reference.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Possible Solution:
I was thinking of using a switch true function to create academic years of the days between the dates provided above. So, if DATE >= "2022-08-22" then "Academic Year 2022" and so forth. Now, my thought is to create a list of 7 1's, 7 2's and for each of the given years down the column. I know that GENERATESERIES can make series of number like 1, 2, 3, 4... down the column but I cannot find any documentation that can show how to make each value repeat 7 times down the column. I am a little more versed in nested for and while loops which could do this iteration in other languages.
User | Count |
---|---|
14 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
25 | |
13 | |
12 | |
8 | |
8 |