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

Join 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

Reply
erezbenmoshe
Advocate I
Advocate I

DATEDIFF

DATEDIFF doesn't show the expected difference.  I am trying to calculate "Months from first purchase".  

Both columns are the same date format.  The difference I get is not correct.

 

This is a calcualted column:

Months from first purchase = DATEDIFF(FactSalesCache[FirstDate], FactSalesCache[Date], MONTH)
 
 

Capture.JPG

 

Thanks,

Erez

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

It looks like you pulled that column into a visual and the field is set to SUM.  My guess is the second line represents 3 records in your data set (4 months diff * 3 = 12) and the third line is covering 2 records.  Try changing the field to show the AVERAGE.

View solution in original post

4 REPLIES 4
nilimarodrigues
Helper III
Helper III

Could it be your date format? I tried with MM/DD/YYYY format and DATEDIFF works perfectly fine.

Another alternate formula could be:

DIFFERENCE = month('SAMPLE'[FIRSTSALE])-month('SAMPLE'[FIRSTPURCHASE])
Nathaniel_C
Community Champion
Community Champion

ddiff.PNG

 

Hi @erezbenmoshe ,

Works here.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




jdbuchanan71
Super User
Super User

It looks like you pulled that column into a visual and the field is set to SUM.  My guess is the second line represents 3 records in your data set (4 months diff * 3 = 12) and the third line is covering 2 records.  Try changing the field to show the AVERAGE.

You are right!! I am embarrassed that I did not figure it out myself 🙂

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.