cancel
Showing results for
Did you mean:
Helper II

## Is date in the last week of the month?

How can I put a 1 in my date table (daily granularity) if the date is in the last week of the month?

1 ACCEPTED SOLUTION
Community Support

Here are the steps you can follow：

1. Create calculated column.

``````Find the first few weeks of the month:
Week of Month =
var _currentweek=WEEKNUM('Table'[Date],1)
var _startweek=WEEKNUM(DATE([Date].[年],[Date].[MonthNo],1),1)
return
_currentweek -_startweek +1``````

When this week is the last week of the month, it is displayed as 1, otherwise, it is displayed as 0

``````put a 1 =
var _1=CALCULATE(MAX('Table'[Week of Month]),FILTER('Table',MONTH('Table'[Date])=MONTH(EARLIER('Table'[Date]))))
return
IF([Week of Month]=_1,1,0)``````

2. Result：

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 REPLIES 2
Community Support

Here are the steps you can follow：

1. Create calculated column.

``````Find the first few weeks of the month:
Week of Month =
var _currentweek=WEEKNUM('Table'[Date],1)
var _startweek=WEEKNUM(DATE([Date].[年],[Date].[MonthNo],1),1)
return
_currentweek -_startweek +1``````

When this week is the last week of the month, it is displayed as 1, otherwise, it is displayed as 0

``````put a 1 =
var _1=CALCULATE(MAX('Table'[Week of Month]),FILTER('Table',MONTH('Table'[Date])=MONTH(EARLIER('Table'[Date]))))
return
IF([Week of Month]=_1,1,0)``````

2. Result：

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User II

measure = SWITCH(TRUE(),

WEEKNUM(EOMONTH('table'[dt])) = WEEKNUM('table'[dt]), 1,0)

Announcements

#### 2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.