Forum Discussion
Mith
3 years agoRegular Visitor
Current Month vs Previous Month
Hi, I was using the below Dax formula for current month and previous month month last 9 months and giving me the accurate answer. Today i noticed after refreshed the data, in my report for CM and...
- 3 years ago
This should work now.
Current month Female = VAR _current_month = MONTH ( EOMONTH ( TODAY (), -1 ) ) VAR _current_year = Year ( EOMONTH ( TODAY (), -1 ) ) RETURN CALCULATE ( [Female_App], FILTER ( Applicant, INT(MONTH ( Applicant[Added Date] )) = INT(_current_month) && INT(YEAR ( Applicant[Added Date] )) = INT(_current_year) ) )previous month Female = VAR _current_month = MONTH ( EOMONTH ( TODAY (), -2 ) ) VAR _current_year = Year ( EOMONTH ( TODAY (), -2 ) ) RETURN CALCULATE ( [Female_App], FILTER ( Applicant, INT(MONTH ( Applicant[Added Date] )) = INT(_current_month) && INT(YEAR ( Applicant[Added Date] )) = INT(_current_year) ) )
Mith
3 years agoRegular Visitor
Thanks for your reply. but i am getting the below error-
calculation error in measure "Applicant[current month female applicant]:Dax comparison operations do no support comparing values of types text with values of type integer. consider using the value or format function to convert one of the values.
Samarth_18
Community Champion
3 years agoMith ,
Please try this:-
Current month Female =
VAR _current_month =
INT(MONTH ( EOMONTH ( TODAY (), -1 ) ))
VAR _current_year =
INT(Year ( EOMONTH ( TODAY (), -1 ) ))
RETURN
CALCULATE (
[Female_App],
FILTER (
Applicant,
MONTH ( Applicant[Added Date] ) = _current_month
&& YEAR ( Applicant[Added Date] ) = _current_year
)
)previous month Female =
VAR _current_month =
INT(MONTH ( EOMONTH ( TODAY (), -2 ) ))
VAR _current_year =
INT(Year ( EOMONTH ( TODAY (), -2 ) ))
RETURN
CALCULATE (
[Female_App],
FILTER (
Applicant,
MONTH ( Applicant[Added Date] ) = _current_month
&& YEAR ( Applicant[Added Date] ) = _current_year
)
)- Mith3 years agoRegular Visitor
This dax formula is not working for me also.
- Samarth_183 years ago
Community Champion
Mith Whats the Error?
One more thing Current month you means Jan and previous month Dec?
- Mith3 years agoRegular Visitor
Getting the same error. I wanted to show Dec as a current month and november as previous month data. applicant added date is up to 12/31/2022.