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
Anonymous
Not applicable

Unable to add WEEKNUM([date]) when I try to make week numbers to be under every month.

I'm trying to get Week numbers by Month, so it goes,

Jan - 1,2,3,4

Feb - 1,2,3,4

Mar - 1,2,3,4,5

like this. 

 

I found a DAX from https://community.powerbi.com/t5/Desktop/How-to-show-week-number-per-month/td-p/83607 and tried @v-micsh-msft 's solution but it doesn't like [date] value in WEEKNUM() in the measure.

 

pbix.PNG

 

I can see the error says it happens when the formula refers to a column that contains many values without specifying an aggregation such as min, max, ect, which I have in my DateKey table.

Can anyone tell me how I can fix it to use Week number by month? 

 

<'DateKey' table>

 

 

DateKey = 
VAR BaseCalendar = CALENDAR(min('All Tickets'[Created Date Time]), max('All Tickets'[Created Date Time]))
    RETURN
    GENERATE (
        BaseCalendar,
        VAR BaseDate = [Date]
        VAR YearDate = YEAR ( BaseDate )
        // VAR WeekNum = 1 + WEEKNUM(BaseCalendar) - WEEKNUM(STARTOFMONTH('All Tickets'[Created Date]))
        VAR MonthNumber = MONTH ( BaseDate )
        VAR YearMonthNumber = YearDate * 12 + MonthNumber - 1
        vAR YearWeek = WEEKDAY( BaseDate )
        RETURN ROW (
            "Day", BaseDate,
            "Year", YearDate,
            "Month Number", MonthNumber,
            "Month", FORMAT ( BaseDate, "mmmm" ),
            "Month Short", FORMAT( BaseDate, "mmm"),
            "Year Month Number", YearMonthNumber,
            "Year Month", FORMAT ( BaseDate, "mmm yy" ),
            "Year Month Short", FORMAT( BaseDate, "yyyy/mmm" ),
            "Week", FORMAT( BaseDate, "dddd"),
            "Week Short", FORMAT( BaseDate, "ddd"),
            "Week Number", WEEKNUM(BaseDate),
            "Quarter", "Q" & FORMAT( BaseDate, "Q"),
            "Year Quarter", FORMAT( BaseDate, "yyyy") & "/Q" & FORMAT( BaseDate, "Q"),
            "Datekey", FORMAT(BaseDate, "yyyymmdd")
        ))

 

 

 
Any help will be appreciated. 
Thanks in advance! 
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

I think you inadvertently created a measure. Delete it and recreate as calculated column.

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

I think you inadvertently created a measure. Delete it and recreate as calculated column.

Anonymous
Not applicable

You're right. I was creating one with measure not column. 

Thanks!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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