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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
HabibAdil
Helper IV
Helper IV

Enquiry Response Time using Datediff where the Dates are in Different Tables

Hi, 

I am trying to calculate monthly average enquiry response time in days, but unable to do so. Please can you help? In the attached example, an opportunity (Opp) can have more than 1 quotes. The response time is based on the when the opp was created and when the first quote was sent. The tables are joined using Opp GUID field. 

Just to add a bit of extra complexity, but not essential. One quote can be assosicated to more than 1 Opp as well.

Datediff Table.PNG

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @HabibAdil ,

 

You could create a rank column at first.

Rank =
RANKX (
    FILTER ( Quote, Quote[GUID] = EARLIER ( Quote[GUID] ) ),
    Quote[Date],
    ,
    ASC,
    DENSE
)

Then use LOOKUPVALUE() or RELATED() function to match the resuilt.

Result1 =
VAR a =
    LOOKUPVALUE ( Opp[Date], Opp[GUID], Quote[GUID] )
RETURN
    IF ( Quote[Rank] = 1, DATEDIFF ( a, Quote[Date], DAY ) )
Result2 =
VAR a =
    RELATED ( Opp[Date] )
RETURN
    IF ( Quote[Rank] = 1, DATEDIFF ( a, Quote[Date], DAY ) )

Then show the average in the visual.

1-1.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

5 REPLIES 5
v-eachen-msft
Community Support
Community Support

Hi @HabibAdil ,

 

You could create a rank column at first.

Rank =
RANKX (
    FILTER ( Quote, Quote[GUID] = EARLIER ( Quote[GUID] ) ),
    Quote[Date],
    ,
    ASC,
    DENSE
)

Then use LOOKUPVALUE() or RELATED() function to match the resuilt.

Result1 =
VAR a =
    LOOKUPVALUE ( Opp[Date], Opp[GUID], Quote[GUID] )
RETURN
    IF ( Quote[Rank] = 1, DATEDIFF ( a, Quote[Date], DAY ) )
Result2 =
VAR a =
    RELATED ( Opp[Date] )
RETURN
    IF ( Quote[Rank] = 1, DATEDIFF ( a, Quote[Date], DAY ) )

Then show the average in the visual.

1-1.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Hi @v-eachen-msft, works great. Thanks for your help!!!

Greg_Deckler
Super User
Super User

You could use LOOKUPVALUE or perhaps take a look at this: https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/td-p/985814

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler Thanks for the help. Unfortunately It did not work for me.

Sample data please. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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