Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Calculate the number of days between two date columns; positive or negative

 

I have two date columns. To calculate the number of days difference between them, I just created a measure =[Date1]-[Date2]. But the resullts are erroneous. I also created a column using the same formula. The numbers with Measure and Calculated column are equal. 

 

When I exported the data out to excel and took the difference, the results are correct. some of the Power BI numbers are off by exact muiples like 2x, 3x. Not sure why. I want the numbers to indicate +ve or -ve difference. 

Please see the screenshot of the table here: https://imgur.com/a/LHs8H

I cant figure out why. Can someone please help. 

 

1 ACCEPTED SOLUTION
srinivt
Microsoft Employee
Microsoft Employee

Can you share the exact DAX expression you used to build the measure and calculated column expressions? How did you import the data? Can you verify that the dates are accurately recognized during import? Finally, how are you verifying the difference in the data-view or a matrix/table visual? If it is matrix/table visual and using a calculated column, very likely it will be aggregated using a SUM aggregation, which could explain why you are seeing 2X, 3X etc results. 

View solution in original post

2 REPLIES 2
srinivt
Microsoft Employee
Microsoft Employee

Can you share the exact DAX expression you used to build the measure and calculated column expressions? How did you import the data? Can you verify that the dates are accurately recognized during import? Finally, how are you verifying the difference in the data-view or a matrix/table visual? If it is matrix/table visual and using a calculated column, very likely it will be aggregated using a SUM aggregation, which could explain why you are seeing 2X, 3X etc results. 

Anonymous
Not applicable

Bingo - the results were being aggregated when I dropped it in the table. Thanks!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.