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

Return date of next Wednesday in a tile

Hey,

 

I am looking for some DAX to use in a measure , which will return the date of the next Wednesday. which I want to display in a tile in the report

I have tried the below but it is not very graceful and additionally it doesn't work (it needs a column cannot use today()).

 

Does anyone have any ideas?

 

var DayNum = WEEKDAY(TODAY(),2)

Return if(DayNum = 1, DATEADD(TODAY(),2,DAY), IF(
DayNum = 2, DATEADD(Today(),1,DAY), IF(
DayNum = 3, Today(), IF(
DayNum = 4, DATEADD(Today(),6,DAY), IF(
DayNum = 5, DATEADD(Today(),5,DAY), IF(
DayNum = 6, DATEADD(Today(),4,DAY), DATEADD(Today(),3,DAY)))))))
1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@Anonymous   

If you are calculating "next wednesday" based on today's date, try this:

 

Please change the “;” to “,” in the measure

 

Next wednesday = 
VAR weeknumtod = WEEKDAY(TODAY()) 
Return 
IF(weeknumtod<5; TODAY()+4-weeknumtod; IF(weeknumtod <8; TODAY() +8-weeknumtod + 3)) 

 

 

 

You may have to tweak it depending on the date you wish to see if today is actually "wednesday" (whether you want to see today's date, or next week's wednesday's date)

 At the moment it will return today’s date if it is wednesday. If you want it to be next wednesday, it being wednesday today, you will need to add am IF(weeknum = 4; TODAY() +7)
at the very beginning of the IF clause in the return statement.
 
You can play around to see the results by hard coding a date in the VAR "seldate" in this measure:
 

 

 

 

Next wednesday (hard coded "today") = 
VAR seldate = DATE(2019;11;16)
VAR weeknumtod = WEEKDAY(seldate)
Return
IF(weeknumtod<5; seldate +4-weeknumtod; IF(weeknumtod <8; seldate +8-weeknumtod + 3))

 

 

 

 

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

@Anonymous   

If you are calculating "next wednesday" based on today's date, try this:

 

Please change the “;” to “,” in the measure

 

Next wednesday = 
VAR weeknumtod = WEEKDAY(TODAY()) 
Return 
IF(weeknumtod<5; TODAY()+4-weeknumtod; IF(weeknumtod <8; TODAY() +8-weeknumtod + 3)) 

 

 

 

You may have to tweak it depending on the date you wish to see if today is actually "wednesday" (whether you want to see today's date, or next week's wednesday's date)

 At the moment it will return today’s date if it is wednesday. If you want it to be next wednesday, it being wednesday today, you will need to add am IF(weeknum = 4; TODAY() +7)
at the very beginning of the IF clause in the return statement.
 
You can play around to see the results by hard coding a date in the VAR "seldate" in this measure:
 

 

 

 

Next wednesday (hard coded "today") = 
VAR seldate = DATE(2019;11;16)
VAR weeknumtod = WEEKDAY(seldate)
Return
IF(weeknumtod<5; seldate +4-weeknumtod; IF(weeknumtod <8; seldate +8-weeknumtod + 3))

 

 

 

 

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






MartynRamsden
Solution Sage
Solution Sage

Hi @Anonymous 

 

Try this (where 'Table'[Column1] is your date column reference):

 

Next Wednesday =
VAR SelDate = SELECTEDVALUE ( 'Table'[Column1] )
VAR DayNo = WEEKDAY ( SelDate )
VAR NextWed =
SWITCH (
    TRUE(),
    DayNo = 1, SelDate+3,
    DayNo = 2, SelDate+2,
    DayNo = 3, SelDate+1,
    DayNo = 4, SelDate+7,
    DayNo = 5, SelDate+6,
    DayNo = 6, SelDate+5,
    DayNo = 7, SelDate+4
)
RETURN NextWed

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.