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
rnambiar
Frequent Visitor

Get the difference between 2 dates and then average it by category

I have a table with 3 columns Entity, Start_Date and End_Date as follows:

EntityStartEnd
A1/1/20241/31/2024
A1/28/20242/12/2024
A5/1/20246/5/2024
B7/31/20248/27/2024
B8/7/202410/6/2024
B9/24/202410/31/2024
C10/22/202412/28/2024
C1/6/20254/15/2025
C3/17/20255/18/2025

 

I am trying to compute the "Average difference" for each entity.  The expected result should be (average difference of start and end for each group)

A = 27

B = 41

C = 76

 

I tried the following DAX code:

AVERAGEX(
        SUMMARIZE('actrec - PVI','actrec - PVI'[Company],'actrec - PVI'[ctcdte],'actrec - PVI'[sttdte]),
        DATEDIFF('actrec - PVI'[ctcdte],'actrec - PVI'[sttdte],DAY)
    )
This just returns the overall average of the 3 categories. 
 
Thanks for your help.
2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

ThxAlot
Super User
Super User

ThxAlot_0-1724453207324.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

4 REPLIES 4
rnambiar
Frequent Visitor

thank you.  this also worked.

ThxAlot
Super User
Super User

ThxAlot_0-1724453207324.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Thank you this worked.

lbendlin
Super User
Super User

lbendlin_0-1724453093232.png

 

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.