Forum Discussion
Countrows for previousmonth
- 2 years ago
pls try this
Measure= VAR _Start =EOMONTH( TODAY(),-2)+1 VAR _End = EOMONTH( TODAY(),-1) RETURN CALCULATE( COUNTROWS(Data), USERELATIONSHIP(Data[Created], 'Calendar'[Date]), DATESBETWEEN('Calendar'[Date] ,_Start,_End )
Thank you Ahmedx
This code now returns the figure that I am expecting.
However, I would be interested to know if somebody could explain why a function exists called PREVIOUSMONTH (https://dax.guide/previousmonth/) that I would have thought could have been used to get to my answer, but instead we have to use code and manipulate it in such a way to go back and forth in time. Just curious 🙂
Thank you all for your help, lots to learn !
Dean
DeanStearn Time intelligence functions are a bit mind boggling at first - I think it took me a few years to fully grasp the ins and outs of them. Lots of testing and trial and error. You can use the Previous Month function, and it will give you the ENTIRE month, not just the dates you have selected, following my same pattern: