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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
kballar1
Helper I
Helper I

SUMX Help

IMG_1781.jpeg

I created a measure using SUMX to get the number of days between two dates so that I could see how many days it takes an account manager to approve something once it's submitted for approval. However now I am seeing issues with it. Some of the results "Lag" are correct but some say "112" lag but the dates are not 112 days in between. I used: 

 

Measure = SUMX(Table1, DATEDIFF(Table1 [Physical Date],Table1 [PriceApproved.date], DAY))

 

1 ACCEPTED SOLUTION

Hi @kballar1 

In your data screenshot, the Physical Date and Price Approved Date are not in Date format. Please make both dates as Date format.
Use Power Query to correct your data datatype

PijushRoy_0-1704393368037.png


Then use the measure

Measure = DATEDIFF(SELECTEDVALUE('Table (2)'[Physical Date]),SELECTEDVALUE('Table (2)'[Price Approved]),DAY)

 

PijushRoy_1-1704393430835.png

 

PijushRoy_2-1704393563383.png

 



You will find all date diff are correct

If solved your requirement, please mark this answer as SOLUTION.

Thanks
Pijush




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





View solution in original post

7 REPLIES 7
Dangar332
Super User
Super User

try below measure 

 

 

measure =
  datediff(
     min('tablename'[physiacl date]),
     min('tablename'[price approved]),
     day
  )

 

Anonymous
Not applicable

Hi @kballar1 ,

Your measure is working fine with my test data. I recreated a measure for you  to test.

Here some steps that I want to share, you can check them if they suitable for your requirement.

Here is my test data:

vheqmsft_0-1704337382542.png

1.Create a measure

Lag = SUMX(
    'Table', 
    INT('Table'[Price Approved] - 'Table'[Physical Date])
)

2.Final output

vheqmsft_1-1704337750896.png

 

Best Regards,
Albert He

 

 Hi,

I tried that but as you can see, it works one some but not the other. There are not 48 days between 12/21/2023-1/02/2024. How do I fix this? 

IMG_1790.png

Hi @kballar1 

In your data screenshot, the Physical Date and Price Approved Date are not in Date format. Please make both dates as Date format.
Use Power Query to correct your data datatype

PijushRoy_0-1704393368037.png


Then use the measure

Measure = DATEDIFF(SELECTEDVALUE('Table (2)'[Physical Date]),SELECTEDVALUE('Table (2)'[Price Approved]),DAY)

 

PijushRoy_1-1704393430835.png

 

PijushRoy_2-1704393563383.png

 



You will find all date diff are correct

If solved your requirement, please mark this answer as SOLUTION.

Thanks
Pijush




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





It was already marked as date I was just presenting the data in a table visual. But I tried the code you suggested and it worked. Thank you! 

PijushRoy
Super User
Super User

HI @kballar1 

Please try below dax

DATEDIFF = DATEDIFF('Table (2)'[Physical Date],'Table (2)'[Price Approved],DAY)

 

Please show the expected outcome based on the sample data you provided. Find how to provide sample data
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

If solved your requirement, please mark this answer as SOLUTION.

Thanks
Pijush




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





 Hi, that didn't work, here is the error message 

IMG_1789.png

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.