Forum Discussion
ohb60
7 years agoFrequent Visitor
Previous month name in a empty table
Hi PBI expert, I'm a beginner and I'm using Json file with relative date (month -1) and I'd like to find the name of the previous month from today's date... So this is how I find the actual m...
- 7 years ago
Finally I found something that works :
PrevMon = FORMAT(EDATE(NOW();-1);"MMMM")
:smileyhappy:
Thanks everyone !
Greg_Deckler
Community Champion
7 years agoTry this:
Measure 2 = VAR __currentMonth = MONTH(EOMONTH(TODAY(),0)) VAR __previousMonth = IF(__currentMonth = 1,12,__currentMonth - 1) VAR __previousYear = IF(__currentMonth = 1,YEAR(TODAY()) - 1,YEAR(TODAY())) RETURN FORMAT(DATE(__previousYear,__previousMonth,1),"mmm")
- ohb607 years agoFrequent Visitor
Greg_Deckler wrote:Try this:
Measure 2 = VAR __currentMonth = MONTH(EOMONTH(TODAY(),0)) VAR __previousMonth = IF(__currentMonth = 1,12,__currentMonth - 1) VAR __previousYear = IF(__currentMonth = 1,YEAR(TODAY()) - 1,YEAR(TODAY())) RETURN FORMAT(DATE(__previousYear,__previousMonth,1),"mmm")
Thank you Greg but it's not working for me...I have this error when I try to validate this new measure :La syntaxe pour '.0' est incorrecte. (DAX(VAR __currentMonth = MONTH(EOMONTH(TODAY().0))VAR __previousMonth = IF(__currentMonth = 1.12,__currentMonth - 1)VAR __previousYear = IF(__currentMonth = 1.YEAR(TODAY()) - 1.YEAR(TODAY()))RETURNFORMAT(DATE(__previousYear,__previousMonth.1),"mmm"))).