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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Kasonga2018
Frequent Visitor

Return cycle number for every first Wednesday and third Wednesday of the month

Hi all,

 

I need help please, I have a date table below, and I want to add a new column that will return an incremental cycle number for every first Wednesday and third Wednesday of the month. Basically for Wed, 03 Jun'20, it should return 1, for Wed, 17 Jun'20, it should return 2, then for Wed, 01 Jul'20, it should return 3 and Wed, 15 Jul'20, it should return 4 and so on. Does anyone know how I can achieve this with DAX?

 

 

Kasonga2018_0-1634734329549.png

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Kasonga2018 You could do something like this, 2 columns:

1st or 3rd Wednesday = 
    VAR __Date = [Date]
    VAR __Year = YEAR([Date])
    VAR __Month = MONTH([Date])
    VAR __EOMonth = EOMONTH([Date],0)
    VAR __Calendar = 
            ADDCOLUMNS(
                CALENDAR(DATE(__Year,__Month,1),__EOMonth),
                "__Weekday",WEEKDAY([Date],2)
            )
    VAR __Calendar1 = 
        ADDCOLUMNS(
            __Calendar,
            "__WedNum",COUNTROWS(FILTER(__Calendar,[__Weekday] = 3 && [Date]<=EARLIER([Date])))
        )
    VAR __1stWed = MAXX(FILTER(__Calendar1,[__Weekday] = 3 && [__WedNum] = 1),[Date])
    VAR __3rdWed = MAXX(FILTER(__Calendar1,[__Weekday] = 3 && [__WedNum] = 3),[Date])
RETURN
    IF(__Date = __1stWed || __Date = __3rdWed,1,BLANK())





Sequential 1st or 3rd Wednesday = 
    IF([1st or 3rd Wednesday] = 1,COUNTROWS(FILTER('Dates',[1st or 3rd Wednesday] = 1 && [Date] <= EARLIER([Date]))),BLANK())


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@Kasonga2018 You could do something like this, 2 columns:

1st or 3rd Wednesday = 
    VAR __Date = [Date]
    VAR __Year = YEAR([Date])
    VAR __Month = MONTH([Date])
    VAR __EOMonth = EOMONTH([Date],0)
    VAR __Calendar = 
            ADDCOLUMNS(
                CALENDAR(DATE(__Year,__Month,1),__EOMonth),
                "__Weekday",WEEKDAY([Date],2)
            )
    VAR __Calendar1 = 
        ADDCOLUMNS(
            __Calendar,
            "__WedNum",COUNTROWS(FILTER(__Calendar,[__Weekday] = 3 && [Date]<=EARLIER([Date])))
        )
    VAR __1stWed = MAXX(FILTER(__Calendar1,[__Weekday] = 3 && [__WedNum] = 1),[Date])
    VAR __3rdWed = MAXX(FILTER(__Calendar1,[__Weekday] = 3 && [__WedNum] = 3),[Date])
RETURN
    IF(__Date = __1stWed || __Date = __3rdWed,1,BLANK())





Sequential 1st or 3rd Wednesday = 
    IF([1st or 3rd Wednesday] = 1,COUNTROWS(FILTER('Dates',[1st or 3rd Wednesday] = 1 && [Date] <= EARLIER([Date]))),BLANK())


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.