Forum Discussion
Date Function returning wrong Date
Hello All,
Found a strange error in powerbi, where it is not able to convert month & year to a date for month 6 only:
below the dax:
Anonymous , Try var day like
var day = Switch(true(),
vw_LoadSummaryINTL[Month] = 2,28,
vw_LoadSummaryINTL[Month] in (4,6,9,11) , 30,
31)or
Transaction Date =
eomonth(date(vw_LoadSummaryINTL[Year], vw_LoadSummaryINTL[Month],1),0)
- Anonymous5 years ago
Anonymous
There are small mistakes, there is only 30 days in June. So change 5 to 6 in your formula:
IF(vw_LoadSummaryINTL[Month]= 6 , 30,Or you may just use the simple version:Transaction Date =var day_= IF(vw_LoadSummaryINTL[Month] = 2,28,IF(vw_LoadSummaryINTL[Month] in {4,6,9,11}, 30, 31))
RETURN DATE([Year],[Month],day_)
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
3 Replies
- amitchandakSuper User
Anonymous , Try var day like
var day = Switch(true(),
vw_LoadSummaryINTL[Month] = 2,28,
vw_LoadSummaryINTL[Month] in (4,6,9,11) , 30,
31)or
Transaction Date =
eomonth(date(vw_LoadSummaryINTL[Year], vw_LoadSummaryINTL[Month],1),0)
- AnonymousNot applicable
Anonymous
There are small mistakes, there is only 30 days in June. So change 5 to 6 in your formula:
IF(vw_LoadSummaryINTL[Month]= 6 , 30,Or you may just use the simple version:Transaction Date =var day_= IF(vw_LoadSummaryINTL[Month] = 2,28,IF(vw_LoadSummaryINTL[Month] in {4,6,9,11}, 30, 31))
RETURN DATE([Year],[Month],day_)
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.- AnonymousNot applicable
Yes, sorry for the error, found that after posting here.
Regardless, I used your simple version and helped me a lot.
thank you for your help!