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.
Hello,
I want to get the date of the last thursday.
For example,
IF today=thursday
return today_date
ELSE
return last_thursday date
How could I do this?
Thank you in advance
Solved! Go to Solution.
@lmfernandez
Create the following measure to get the desired results:
Date Measure =
var __day = FORMAT(TODAY(),"ddd") return
IF(
__day = "Thu",
TODAY(),
MAXX( FILTER( ADDCOLUMNS( CALENDAR(TODAY()-6,TODAY()-1) , "wDay" , WEEKDAY([Date],2) ), [wDay] = 4 ),[Date] )
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@lmfernandez
Create the following measure to get the desired results:
Date Measure =
var __day = FORMAT(TODAY(),"ddd") return
IF(
__day = "Thu",
TODAY(),
MAXX( FILTER( ADDCOLUMNS( CALENDAR(TODAY()-6,TODAY()-1) , "wDay" , WEEKDAY([Date],2) ), [wDay] = 4 ),[Date] )
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hey @lmfernandez ,
from your syntax I guess you want to solve that in Power Query.
You can check which day the date is with the function Date.DayOfWeek. The order starts with Sunday = 1, so Thursday is a 5.
Then you can do the math and subtract it from the date.
In DAX you can use the same approach with the WEEKDAY function.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
99 | |
97 | |
85 | |
70 | |
67 |
User | Count |
---|---|
116 | |
109 | |
94 | |
79 | |
72 |