cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
ivandgreat
Helper I
Helper I

Monthly Cutoff date

I am attempting to create a query that uses calendar dates to include all items that fall on my "cutoff" date to happen each month.  The Cutt off date is the 25th of each month. If my date is Jan. 15, it should fall under Month of Jan, but if it's Jan. 26, it should be on Feb. on so on also for December that should include all items from Nov. 26 until Dec. 31.

i have a table that has a date, i wanted to add a column month for each item that falls on that cutoff.

I am stuck creating a conditional column that will set the Cutoff date correctly if the dates fall on 25th of the month.

Any ideas?  

 

item nameDateInclude in Month
item11/15/2021Jan. 1, 2021
item211/26/2021Dec. 1, 2021
1 ACCEPTED SOLUTION
JoeBarry
Solution Sage
Solution Sage

Hi @ivandgreat 

 

I would approach this in Power Query 

 

Create a custom column in your table and something similar replacing the Date column with your date column name

 

if Date.Day([Date]) >= 26 and Date.Month([Date]) >= 11 and 
Date.Day([Date]) <= 31 and Date.Month([Date]) <= 12 then #date(Date.Year([Date]), 12, 1) else

if Date.Day([Date]) >= 26  then Date.StartOfMonth(Date.AddMonths([Date], +1))
 else  Date.StartOfMonth([Date])

 

If you are then using a Date Table and want to make calculations on the the Cut off, create either a one to many relationship with the new Cutoff date column or create the same relationship and have it set as in active relationship. When creating measures, use USERELATIONSHIP to activate the relationship

 

Hope this helps

 

Joe

 

If this post helps, then please Accept it as the solution

View solution in original post

6 REPLIES 6
JoeBarry
Solution Sage
Solution Sage

Hi @ivandgreat 

 

I would approach this in Power Query 

 

Create a custom column in your table and something similar replacing the Date column with your date column name

 

if Date.Day([Date]) >= 26 and Date.Month([Date]) >= 11 and 
Date.Day([Date]) <= 31 and Date.Month([Date]) <= 12 then #date(Date.Year([Date]), 12, 1) else

if Date.Day([Date]) >= 26  then Date.StartOfMonth(Date.AddMonths([Date], +1))
 else  Date.StartOfMonth([Date])

 

If you are then using a Date Table and want to make calculations on the the Cut off, create either a one to many relationship with the new Cutoff date column or create the same relationship and have it set as in active relationship. When creating measures, use USERELATIONSHIP to activate the relationship

 

Hope this helps

 

Joe

 

If this post helps, then please Accept it as the solution

Thanks. This one works fine.

Hi @ivandgreat 

 

If it works, can yopu accept it as a solution, it helps other user find the correct answer easier for similar questions

 

Thanks

Joe

mlsx4
Super User
Super User

Hi @ivandgreat 

 

You can do the following:

 

if Date.Day([Date])<25 then #date(Date.Year([Date]),Date.Month([Date]),1) else if Date.Month([Date])=12 then #date(Date.Year([Date]),Date.Month([Date]),1) else #date(Date.Year([Date]),Date.Month([Date])+1,1)

mlsx4_0-1695627964798.png

 

Thanks. This one works fine.

Hi @ivandgreat 

 

I'm glad it works. Please, mark it as solved for other users who may need it

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors