Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
I am having an issue with different calculation of month using Excel and PowerBI.
I have following DAX:
First, when I calculate the difference of month betwen 10/1/2025 & 10/28/2022, in Excel, it shows 35 months, but in PowerBI, it shows 36.
So, I ended up subtracting 1 in order to match with Excel.
When I Googled, it says 35 .1 month.
Next challenge is this:
Difference between: 10/1/2025 & 9/1/2022.
In Excel, it says 37 months.
In Google, it says 37 months.
But, using the measure that I have, it says 37 months in PowerBI.
So, I cannot adjust it by subtracting 1 on PowerBI in this case.
Is there better DAX formula that I could use for more accurate calculation of month?
Thanks.
Solved! Go to Solution.
Hi,
As per MS documentation,
https://learn.microsoft.com/en-us/dax/datediff-function-dax , DATEDIFF doesn’t care about completed months, and it counts month boundaries crossed, which means how many times the calendar month changed, not full months. So from 10/28/2022 to 10/1/2025, it crosses month boundaries 36 times, even though it’s only 35 full months elapsed.
That’s why Power BI returns 36.
To match Excel, you can add a condition check in your meausre,
Updated Measure =
VAR StartDate = FIRSTDATE('Table1'[Survey Date])
VAR EndDate = LASTDATE('Table2'[Month Year])
VAR MonthDiff = DATEDIFF(StartDate, EndDate, MONTH)
VAR Adjust =
IF(DAY(EndDate) < DAY(StartDate), 1, 0)
RETURN
MonthDiff - Adjust
Hi @JustinDoh1
You also can try below measure:
DurationMonth = 
VAR StartDate = dt"2022-10-28" //FIRSTDATE('Table1'[Survey Date])
VAR EndDate = dt"2025-10-1"    //LASTDATE('Table2'[Month Year])
VAR MonthNode = 
    SELECTCOLUMNS(
        GENERATESERIES(0,1000),
        "MonthNbr",[Value],
        "Date",EDATE(StartDate,[Value])
    )
RETURN
MAXX(FILTER(MonthNode,[Date]<=EndDate),[MonthNbr])
Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !
Thank you~
Hi @JustinDoh1
You also can try below measure:
DurationMonth = 
VAR StartDate = dt"2022-10-28" //FIRSTDATE('Table1'[Survey Date])
VAR EndDate = dt"2025-10-1"    //LASTDATE('Table2'[Month Year])
VAR MonthNode = 
    SELECTCOLUMNS(
        GENERATESERIES(0,1000),
        "MonthNbr",[Value],
        "Date",EDATE(StartDate,[Value])
    )
RETURN
MAXX(FILTER(MonthNode,[Date]<=EndDate),[MonthNbr])
Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !
Thank you~
Hi,
As per MS documentation,
https://learn.microsoft.com/en-us/dax/datediff-function-dax , DATEDIFF doesn’t care about completed months, and it counts month boundaries crossed, which means how many times the calendar month changed, not full months. So from 10/28/2022 to 10/1/2025, it crosses month boundaries 36 times, even though it’s only 35 full months elapsed.
That’s why Power BI returns 36.
To match Excel, you can add a condition check in your meausre,
Updated Measure =
VAR StartDate = FIRSTDATE('Table1'[Survey Date])
VAR EndDate = LASTDATE('Table2'[Month Year])
VAR MonthDiff = DATEDIFF(StartDate, EndDate, MONTH)
VAR Adjust =
IF(DAY(EndDate) < DAY(StartDate), 1, 0)
RETURN
MonthDiff - Adjust
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
            | User | Count | 
|---|---|
| 8 | |
| 5 | |
| 5 | |
| 4 | |
| 3 | 
| User | Count | 
|---|---|
| 24 | |
| 11 | |
| 10 | |
| 9 | |
| 8 |