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.
I have a date column. I want to create another calculated date column where whenever it shows the first Wednesday in the current month and it will say "Default Day" otherwise it will show date from the date column. Is this possible?
I was using the following calculated column measure:
Solved! Go to Solution.
Hi, @rschaudhr
You can create a Calculated column as following.
Default Date =
VAR cur_day =
NOW ()
VAR first_wes =
CALCULATE (
SELECTEDVALUE ( 'SQL Results (3)'[DATE_] ),
FILTER (
ALL ( 'SQL Results (3)'[DATE_] ),
YEAR ( 'SQL Results (3)'[DATE_] ) = YEAR ( cur_day )
&& MONTH ( 'SQL Results (3)'[DATE_] ) = MONTH ( cur_day )
&& DAY ( [DATE_] ) >= 1
&& DAY ( [DATE_] ) <= 7
&& WEEKDAY ( [DATE_], 3 ) = 2
)
)
RETURN
CONVERT (
IF (
'SQL Results (3)'[DATE_] = first_wes,
"Default Day",
'SQL Results (3)'[DATE_]
),
STRING
)
The result looks like this:
Here is the sample.
Best Regards,
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello,
I need help as well, I used the fomula you guys supplied here, but its not working. Please help.
Hi, @rschaudhr
You can create a Calculated column as following.
Default Date =
VAR cur_day =
NOW ()
VAR first_wes =
CALCULATE (
SELECTEDVALUE ( 'SQL Results (3)'[DATE_] ),
FILTER (
ALL ( 'SQL Results (3)'[DATE_] ),
YEAR ( 'SQL Results (3)'[DATE_] ) = YEAR ( cur_day )
&& MONTH ( 'SQL Results (3)'[DATE_] ) = MONTH ( cur_day )
&& DAY ( [DATE_] ) >= 1
&& DAY ( [DATE_] ) <= 7
&& WEEKDAY ( [DATE_], 3 ) = 2
)
)
RETURN
CONVERT (
IF (
'SQL Results (3)'[DATE_] = first_wes,
"Default Day",
'SQL Results (3)'[DATE_]
),
STRING
)
The result looks like this:
Here is the sample.
Best Regards,
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Show your expected result with an example.
Default Date =
var a = YEAR('SQLresults (3)'[DATE_])*100+MONTH('SQLresults (3)'[DATE_])
var m = CALCULATE(min('SQLresults (3)'[DATE_]),'SQLresults (3)',YEAR('SQLresults (3)'[DATE_])*100+MONTH('SQLresults (3)'[DATE_])=a , WEEKDAY('SQLresults (3)'[DATE_],2)=3)
return if('SQLresults (3)'[DATE_]=m,"Default Day",format('SQLresults (3)'[DATE_],"MM/dd/YYYY"))
Thank you for providing this dax calculation. Unfortunately, it shows all the first Wednesday of every month. I was looking for first Wednesday for the current month.
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 |
---|---|
114 | |
98 | |
86 | |
70 | |
62 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |