Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Tome_05
Helper III
Helper III

How do I create a calendar query

I am always grateful for your help.

Now, I would like to create a calendar query like the attached image in PowerBI, how can I create it? Create a calendar from April 22, 2022, with April 22nd to April 28th as week 1, April 29th to May 5th as week 2, and so on. I want to be able to automatically do the 3rd and 4th weeks every day.

 

スクリーンショット 2022-08-18 093912.jpg

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Tome_05 

pls try this

月 = month('Table'[日付])&"月"

周 = "第"&rounddown(('Table'[日付]-min('Table'[日付]))/7,0)+1 & "周"

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@Tome_05 

pls try this

月 = month('Table'[日付])&"月"

周 = "第"&rounddown(('Table'[日付]-min('Table'[日付]))/7,0)+1 & "周"

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@Tome_05 , refer if my blogs can help

https://amitchandak.medium.com/cheat-sheet-power-bi-4-4-4-and-4-4-5-calendar-786f76da7d92

https://medium.com/chandakamit/cheat-sheet-calendar-that-starts-with-any-date-of-the-month-just-two-...

 

You need move FY Start date

 

var _cal =
ADDCOLUMNS( CALENDAR(DATE(2018,_FYENDMonth+1,01), _end)
, "Month Year" , FORMAT([Date], "MMM-YYYY")
, "Month year Sort" , Year([Date])*100 + month([date])
, "month start date" , EOMONTH([Date],-1)+1
, "month end date" , EOMONTH([Date],0)
, "FY year Start Date", if(month([Date])<=_FYENDMonth, EOMONTH([Date],-1*month([Date])- _FYRemain) ,EOMONTH([Date],-1*month([Date])+_FYENDMonth ) )+1
, "FY year End Date", if(month([Date])<=_FYENDMonth, EOMONTH([Date],_FYENDMonth-1*month([Date])) ,EOMONTH([Date],12-1*(month([Date])- _FYENDMonth) ))
,"Weekday name", format([date], "dddd")
, "Weekday", WEEKDAY([Date],2)
,"Start Week Date" , [Date] -1* WEEKDAY([Date],2) +1
,"End Week Date" , [Date] + 7 -1* WEEKDAY([Date],2)
, "Cal Year",year([date]))
Var _cal_cal2 =AddColumns( _cal,
"FY" , Year([FY year Start Date]),
"FY Month" , Datediff([FY year Start Date], [month start date],MONTH)+1 ,
"FY Qtr" , Quotient(Datediff([FY year Start Date], [month start date],MONTH),3)+1 ,
"FY Qtr Start" , Eomonth([FY year Start Date],Quotient(Datediff([FY year Start Date], [month start date],MONTH),3)*3-1)+1 ,
"FY Qtr End" , Eomonth([FY year Start Date],Quotient(Datediff([FY year Start Date], [month start date],MONTH),3)*3+2) ,
"FY Week Start",[FY year Start Date] -WEEKDAY([FY year Start Date],2)+1
)
//var _end = ENDOFYEAR(Sales[Sales Date])
return
ADDCOLUMNS(_cal_cal2,
"FY Year Month" , [FY]*100 + [FY Month]
,"FY Week" , QUOTIENT(DATEDIFF([FY Week Start],[Date],day),7)+1
,"FY Week No" , [FY]*100 + QUOTIENT(DATEDIFF([FY Week Start],[Date],day),7)+1

)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors