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
Sourav_86_Babai
Frequent Visitor

Dax Required to return 1st Tuesday and 3rd Tuesday of a particular Month from a column(Date opened)

Dax Required to return 1st Tuesday and 3rd Tuesday of a particular Month from a column (Date opened) which contains date in the format like 01.Jan.2020.

 

Also, i had Split Month Name, Day, Day Name from the above column to all separate columns but after this not able to return 1st Tuesday and 3rd Tuesday of a particular Month.

Please help.

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

You want the Date of the 1st Tuesday and 3rd Tuesday? You could do this:

First Tuesday =
MINX(FILTER('Calendar',WEEKDAY([Date],1) = 3),[Date])


@ 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

Greg_Deckler
Super User
Super User

Here is Third Tuesday:

Third Tuesday =
VAR __Table =
ADDCOLUMNS(
FILTER('Calendar',WEEKDAY([Date],1) = 3),
"Order",COUNTROWS(FILTER('Calendar',WEEKDAY([Date],1) = 3 && 'Calendar'[Date] <= EARLIER('Calendar'[Date])))
)
RETURN
MAXX(FILTER(__Table,[Order]=3),[Date])

@ 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

9 REPLIES 9
Greg_Deckler
Super User
Super User

Here is Third Tuesday:

Third Tuesday =
VAR __Table =
ADDCOLUMNS(
FILTER('Calendar',WEEKDAY([Date],1) = 3),
"Order",COUNTROWS(FILTER('Calendar',WEEKDAY([Date],1) = 3 && 'Calendar'[Date] <= EARLIER('Calendar'[Date])))
)
RETURN
MAXX(FILTER(__Table,[Order]=3),[Date])

@ 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...

1st and Third tuesday shall i create as Measure or new Column?

I created measures. Probably could be adapted for a column if you got rid of aggregations around certain column references.


@ 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...

Third Tuesday is not working as i checked with Measures and used a slicer as visualization:

 

3rd Tuesday =
VAR __Table =
ADDCOLUMNS(FILTER('New FR 2020',WEEKDAY([Date opened].[Date],1) = 3),
"Order",COUNTROWS(FILTER('New FR 2020',WEEKDAY([Date opened].[Date],1) = 3 && 'New FR 2020'[Date opened].[Date] <= EARLIER('New FR 2020'[Date opened].[Date]))))
RETURN
MAXX(FILTER(__Table,[Order]=3),[Date opened].[Date])

@Sourav_86_Babai  - Going to have to let me know what is going on in more detail. I based my calculations on having a date table. See attached PBIX file. Is that what you are using as well or are you using some table that has date holes in it?

 

 


@ 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...

@Greg_Deckler 

Hi,

 

Thank you for your reply.
I guess something is missing out.

As per your file:

Date = Opened Date

Calender = New FR 2020

 

I tried to make changes but it is not working.

 

Capture.JPG

 

Regards.

 

 
Greg_Deckler
Super User
Super User

You want the Date of the 1st Tuesday and 3rd Tuesday? You could do this:

First Tuesday =
MINX(FILTER('Calendar',WEEKDAY([Date],1) = 3),[Date])


@ 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...
Anonymous
Not applicable

Thanks @Greg_Deckler, your measure formula works well . Do you know if there is a way to mark a date asthe first tuesday of the month, within the Calendar table definition? I.e. Without having to create a separate measure?

@Anonymous - So as a column you would need something like:

 

First Tuesday Column =
MINX(

  FILTER(

    'Calendar',

    WEEKDAY([Date],1) = 3 &&

      YEAR([Date])=YEAR(EARLIER([Date])) &&

      MONTH([Date])=MONTH(EARLIER([Date]))

  ),

  [Date]

)


@ 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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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