cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thisisausername
Helper II
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
v-yangliu-msft
Community Support
Community Support

Hi  @thisisausername  ,

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:

v-yangliu-msft_0-1611280680770.png

 

You can downloaded PBIX file from here.

 

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.

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @thisisausername  ,

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:

v-yangliu-msft_0-1611280680770.png

 

You can downloaded PBIX file from here.

 

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.

View solution in original post

pranit828
Super User II
Super User II

Hi @thisisausername 

measure = SWITCH(TRUE(),

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




PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Top Solution Authors
Top Kudoed Authors