Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreShape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.
Hi, I've thoroughly reviewed the other posts on this topic and none of them have a solution that works for my situation. I need to calculate the months difference between two dates, and in some cases, the start date is greater than the end date. I cannot just subtract the dates because I need the Months, not the Days. I've tried to modify the following solutions from previous posts but I get the same error each time:
1)
DateDiffMeasure := IF ( [StartDateField] > [EndDateField], 0 - DATEDIFF ( [EndDateField], [StartDateField], Month ), DATEDIFF ( [StartDateField], [EndDateField], Month ) )
2)
Days = SWITCH ( TRUE (), [StartDateField] > [EndDateField], -1 * DATEDIFF ( [EndDateField], [StartDateField], Month ), [EndDateField] > 'Table'[Target], DATEDIFF ( [StartDateField], [EndDateField], Month ), 0 )
I get the same Datediff error (start date cannot be greater than the end date) regardless of what option I try from previous posts on this topic.
I tried your DAX formula in Feb 2017 version of Power BI Desktop and did not get the Datediff error as below. Could you please provide your PBIX file to me so that I can have a check on it?
Best Regards,
Herbert
User | Count |
---|---|
89 | |
88 | |
85 | |
81 | |
49 |
User | Count |
---|---|
150 | |
142 | |
112 | |
73 | |
55 |