Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I'm trying to write a DAX measure and having errors when trying to compare two dates. I had found some answers here in the past for other issues I ran into but am relatively new to DAX and M. Basically I want to determine if two column's dates are within the same month. The second column has NULL Values if they don't have a date associated with that yet.
So originally I was going to use DateDiff using STARTOFMONTH[Date1], vs STARTOFMONTH[Date2]. That way I could see if there was any difference and make it insanely simple.
Problem is Date2 often has NULL values (As its expected to), basically checking to see if someone registered and then un-registered within the same month. Any help is appreciated.
Solved! Go to Solution.
I actually found a solution, creating a new COLUMN:
Same Month Unregister = SWITCH(True,Month(Query1[register_date]) == Month(Query1[unregister_date]) && Year(Query1[register_date]) == Year(Query1[unregister_date]), "Yes", 1=1, "No")
I actually found a solution, creating a new COLUMN:
Same Month Unregister = SWITCH(True,Month(Query1[register_date]) == Month(Query1[unregister_date]) && Year(Query1[register_date]) == Year(Query1[unregister_date]), "Yes", 1=1, "No")
@tagban ,
Personally, would use the MONTH function. Create a calculated column:
SameMonth = SWITCH(
TRUE()
ISBLANK([Column2]), 0, //or whatever you need to enter here
MONTH([Column1]) = Month([Column2]), "SameMonth" ) //or whatever
Trust something like this will work for you.
Regards,
I wound up finding a solution using a new Column. Probably not the most elegant and yours actually works as well, but I also have to compare year since this is 9 years of data to look back on. Thank you so much for offering assistance!
User | Count |
---|---|
98 | |
87 | |
77 | |
67 | |
63 |
User | Count |
---|---|
110 | |
95 | |
95 | |
64 | |
58 |