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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DicksonJeff
New Member

Trying to calculate sum on a metric (DateDiff)

I have a metric calculating the difference between the first and last date in a series of date changes. 

 

Days Close Date Delta = DATEDIFF([First Close Date],[Last Close Date],DAY)
First Close Date is the min of TableName.CloseDate likewise the last close date is the max tablename.closedate table and field. 

My objective is to next create another metric that totals all of the differences that are found. Below is a table showing records and the date difference (delta) if there is one. Currently my formula to total the differences comes to 5 which is the count. I would like to see a total of 572 as an example. The logic seems simple but not being able to use a metric in a sum function is throwing me a wrench. 
 
DicksonJeff_0-1624913925873.png

 

Thanks in advance

2 ACCEPTED SOLUTIONS
AlexisOlson
Super User
Super User

You can use a SUMX like this:

DeltaTotal =
SUMX ( VALUES ( TableName[Column] ), [Days Close Date Delta] )

Where [Column] is whatever column is the lowest level of granularity in your visual.

View solution in original post

Thank you! i had been trying something similar but basing it off of the date field and not the id field. that fixed my issue!

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

You can use a SUMX like this:

DeltaTotal =
SUMX ( VALUES ( TableName[Column] ), [Days Close Date Delta] )

Where [Column] is whatever column is the lowest level of granularity in your visual.

Thank you! i had been trying something similar but basing it off of the date field and not the id field. that fixed my issue!

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.