Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
99 | |
86 | |
35 | |
35 |
User | Count |
---|---|
150 | |
100 | |
78 | |
61 | |
56 |