Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
I am using the following to determine number of years between two dates in DAX. I don't think my results are correct. Is the measure, correct? Both fields are Date Fields.
Solved! Go to Solution.
Hi @bdehning
It depends on what you are trying to do.
The function in the way you wrote it can work as a calculated column because it requires scalar values and returns the number of calendar years that were between the two values. In other words, if your two dates are within the same calendar year, for example 2023, you will get 0, and if one date is 2022 and the other 2023, you will get 1 even if it was only one month between the two dates.
If you are interested in accurately returning the number of years, including fractions, you can use the function:
Years_with_parts = ([Loss Date]-[Claimant Hire Date])/365
If you need a measure and not a calculated column you need to calculate the function on some aggregated form like :
Hi @bdehning
Again, it depends on the needed logic.
If you need calendar months then :
Hi @bdehning
It depends on what you are trying to do.
The function in the way you wrote it can work as a calculated column because it requires scalar values and returns the number of calendar years that were between the two values. In other words, if your two dates are within the same calendar year, for example 2023, you will get 0, and if one date is 2022 and the other 2023, you will get 1 even if it was only one month between the two dates.
If you are interested in accurately returning the number of years, including fractions, you can use the function:
Years_with_parts = ([Loss Date]-[Claimant Hire Date])/365
If you need a measure and not a calculated column you need to calculate the function on some aggregated form like :
What would be needed to add to your datedif file to show number of months from Claimant Hire Date and Loss Date?
Hi @bdehning
Again, it depends on the needed logic.
If you need calendar months then :
It worked fine and would months with parts be the most accurate measure to use to use number of months after claimant hire date. I noticed Pandora shows 25 months for Sum of Months and 26.13 for Sum of months with parts.
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 48 | |
| 40 | |
| 38 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 68 | |
| 66 | |
| 30 | |
| 26 | |
| 25 |