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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Whoule
Helper I
Helper I

Increment column every 1st and 15th of the month

Hi,

 

I have created a date table and now I want a column that returns a number incremented by 1 every 1st and 15th of the month.

 

Here is an example:

2023-12-12

   1

2023-12-13   1
2023-12-14   1
2023-12-15   2
2023-12-16   2
2023-12-17   2

 

Any idea on how to achieve this? Thanks !

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Whoule Try this:

Column = 
  VAR __Date = [Date]
  VAR __Day = DAY( [Date] )
  VAR __Table = FILTER( 'Table', [Date] <= __Date && ( DAY( [Date] ) = 1 || DAY( [Date] = 15 ) )
  VAR __Result = COUNTROWS( __Table )
RETURN
  __Result

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Ahmedx
Super User
Super User

Sorry, I found a mistake, now everything is correct

Screenshot_1.png

Hi @Ahmedx,

This doesn't work as some months have 31 days so after one month dividing by 15 doesnt work anymore.

pls try again

Screenshot_7.png

Still doesn't work. The ID needs to change not every 15 days but only on the 1st and 15th of each month.

where there are 31 days or 29 what to do

Greg_Deckler
Super User
Super User

@Whoule Try this:

Column = 
  VAR __Date = [Date]
  VAR __Day = DAY( [Date] )
  VAR __Table = FILTER( 'Table', [Date] <= __Date && ( DAY( [Date] ) = 1 || DAY( [Date] = 15 ) )
  VAR __Result = COUNTROWS( __Table )
RETURN
  __Result

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

March 2024 PBI Gallery Image

Power BI Monthly Update - March 2024

Check out the March 2024 Power BI update to learn about new features.