The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi Community,
Is it possible to create a variable within a measure that returns the date of the last Thursday of the current month dynamically, so for example, we are now in October 2022 and the date of the last Thursday of this month is 27th October 2022. Next month it will be 24th November 2022 etc.
Preferably, this would be calculated independant of any tables if possible?
Solved! Go to Solution.
Figured it out:
VAR __Start = DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 )
VAR __END = EOMONTH ( TODAY (), 0 )
VAR __LastThursdayofCurrentMonth =
MAXX (
FILTER (
ADDCOLUMNS ( CALENDAR ( __Start, __END ), "Day", WEEKDAY ( [Date] ) ),
[Day] = 5
),
[Date]
)
Figured it out:
VAR __Start = DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 )
VAR __END = EOMONTH ( TODAY (), 0 )
VAR __LastThursdayofCurrentMonth =
MAXX (
FILTER (
ADDCOLUMNS ( CALENDAR ( __Start, __END ), "Day", WEEKDAY ( [Date] ) ),
[Day] = 5
),
[Date]
)
i
If you have a date table make sure that you have the Weekday number (Weekday(Date[date])
and after the measure is :
calculate(max(date[date]), Weekday=4)
User | Count |
---|---|
65 | |
62 | |
60 | |
53 | |
28 |
User | Count |
---|---|
181 | |
82 | |
67 | |
47 | |
44 |