March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
I am completly new to Dax and will appreciate any assistance here. I have come across this dynamic calendar based on DAX and Ifound it very simple to use. the issue is that I need to expand it to inlcude other columns such as Quarters financial YearQuarter etc..
What is the syntax for including the list below in the current code?
YearNumber
DayWeek
WeekNumber
WeekEnding
DayName
CalendarQtr
FinancialQtr
FinancialYr (FY)
MonthName
CalendarMonth
Here is the working script at the moment.
Dates =
VAR BaseCalendar =
CALENDARAUTO (6)
RETURN
GENERATE (
BASECALENDAR,
VAR BASEDATE = [DATE] VAR DayDate = DAY([DATE])
VAR YEARDATE = YEAR ( BASEDATE )
VAR MONTHNUMBER = MONTH ( BASEDATE )
VAR YEARMONTHNUMBER = YEARDATE * 12 + MONTHNUMBER -1
RETURN ROW (
"DAY", DayDate,
"YEAR", YEARDATE,
"MONTH NUMBER", MONTHNUMBER,
"MONTH", FORMAT ( BASEDATE, "MMMM" ),
"YEAR MONTH NUMBER", YEARMONTHNUMBER,
"YEAR MONTH", FORMAT ( BASEDATE, "MMM YY" )
)
)
Thanks
D.
Solved! Go to Solution.
Hi @esterdid
I think this might be close
Dates = VAR BaseCalendar = CALENDAR(date(2016,1,1),today()) RETURN GENERATE ( BASECALENDAR, VAR BASEDATE = [DATE] VAR DayDate = DAY([DATE]) VAR YEARDATE = YEAR ( BASEDATE ) VAR MONTHNUMBER = MONTH ( BASEDATE ) VAR YEARMONTHNUMBER = YEARDATE * 12 + MONTHNUMBER -1 VAR FINANCIALQTR = SWITCH( TRUE(), MONTH([Date]) IN {7,8,9} , 1 , MONTH([Date]) IN {10,11,12} , 2 , MONTH([Date]) IN {1,2,3} , 3 , 4) VAR FINANCIALYR = IF( MONTH([Date]) >=7 , YEARDATE , YEARDATE - 1) RETURN ROW ( "DAY", DayDate, "YEAR", YEARDATE, "MONTH NUMBER", MONTHNUMBER, "MONTH", FORMAT ( BASEDATE, "MMMM" ), "YEAR MONTH NUMBER", YEARMONTHNUMBER, "YEAR MONTH", FORMAT ( BASEDATE, "MMM YY" ), ------------------------------ "Week Number",WEEKNUM([Date]), "Week Ending",[Date] + (6-(WEEKDAY([Date],3))), "Day Name" , FORMAT([Date],"DDDD"), "CalendarQtr" , INT(MONTH([Date]) / 4) + 1 , -- "FinancialQtr" , "FYQ" & FINANCIALQTR , "FinancialYr" ,"FY" & FINANCIALYR, "FinancialYrQtr" , FINANCIALQTR & FINANCIALYR ) )
Here are some suggestions for a starters,
"Week Number",WEEKNUM([Date]), "Week Ending",[Date] + (6-(WEEKDAY([Date],3))), "Day Name" , FORMAT([Date],"DDDD"), "CalendarQtr" , INT(MONTH([Date]) / 4) + 1
Just add these to your RETURN ROW function.
Thanks Phil,
those worked, the remaining straight forward as well? expecially working out the financial year (e.g. FY17) and financial year qarters?
FinancialQtr (e.g. FYQ1)
FinancialQtr (e.g. FYQ12017)
FinancialYr (FY17)
Thanks
When does your financial year start?
It starts in July (07). Thanks
Hi @esterdid
I think this might be close
Dates = VAR BaseCalendar = CALENDAR(date(2016,1,1),today()) RETURN GENERATE ( BASECALENDAR, VAR BASEDATE = [DATE] VAR DayDate = DAY([DATE]) VAR YEARDATE = YEAR ( BASEDATE ) VAR MONTHNUMBER = MONTH ( BASEDATE ) VAR YEARMONTHNUMBER = YEARDATE * 12 + MONTHNUMBER -1 VAR FINANCIALQTR = SWITCH( TRUE(), MONTH([Date]) IN {7,8,9} , 1 , MONTH([Date]) IN {10,11,12} , 2 , MONTH([Date]) IN {1,2,3} , 3 , 4) VAR FINANCIALYR = IF( MONTH([Date]) >=7 , YEARDATE , YEARDATE - 1) RETURN ROW ( "DAY", DayDate, "YEAR", YEARDATE, "MONTH NUMBER", MONTHNUMBER, "MONTH", FORMAT ( BASEDATE, "MMMM" ), "YEAR MONTH NUMBER", YEARMONTHNUMBER, "YEAR MONTH", FORMAT ( BASEDATE, "MMM YY" ), ------------------------------ "Week Number",WEEKNUM([Date]), "Week Ending",[Date] + (6-(WEEKDAY([Date],3))), "Day Name" , FORMAT([Date],"DDDD"), "CalendarQtr" , INT(MONTH([Date]) / 4) + 1 , -- "FinancialQtr" , "FYQ" & FINANCIALQTR , "FinancialYr" ,"FY" & FINANCIALYR, "FinancialYrQtr" , FINANCIALQTR & FINANCIALYR ) )
Hi Phil - Could you give syntax for calculating fiscal month number, if my fiscal month is starting in April?
Thanks Phil.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |