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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Poo1405
Frequent Visitor

calculate the days between two date( but two dates in a columns)

I need to calculate the days between two dates in a couple of rows (you can see clearly when seeing the screenshot below) base on other attributes like "leadid" and "campaign". my data set has lots of couples like this, the clear difference that can easily find is one row has "statuslead": ready to call and another is called and the date of its row, the rest are the same information.

 

I have consulted many other posts in the community about how to calculate the days between two dates but most of them are from 2 different columns.

However, it is not suitable for my case, I want to calculate the average of the days between 2 rows has the same information but different date based on leadid. In addition, as far as I can see, the row has statuslead: ready to call is always comes before the row has statuslead: called. Moreover, I also want the return result to be a large number or zero (>= 0) to eliminate the cases where rows have no 2 status to be able to match and calculate.

 

Poo1405_0-1633954917866.png

 

I need help from everyone, Thanks for taking the time to take a look at my post!! 

I also share my .pbix file with everyone to easier to observe!!! 
https://drive.google.com/file/d/1fDhVfvHzE6gKbL6OMFhomgoAqi7gWsLJ/view?usp=sharing

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Poo1405 ,

 

For avg, max, etc., try this:

Avg by campaign =
AVERAGEX ( VALUES ( 'file combine'[leadid] ), [DateDiff_Call] )
Max by campaign =
MAXX ( VALUES ( 'file combine'[leadid] ), [DateDiff_Call] )

Icey_1-1634199164451.png

In addition, [Date_Diff] measure is calculated based on date1 of each leadid, if you want to show it independently, what are the implications of the results you expect to display?

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Icey
Community Support
Community Support

Hi @Poo1405 ,

 

Please check if this is what you want:

DateDiff_Call =
VAR LeadStatusCount =
    CALCULATE (
        DISTINCTCOUNT ( 'file combine'[statusLead] ),
        ALLEXCEPT ( 'file combine', 'file combine'[leadid], 'file combine'[campaign] )
    )
VAR t =
    FILTER (
        ALLEXCEPT ( 'file combine', 'file combine'[leadid], 'file combine'[campaign] ),
        LeadStatusCount = 2
    )
VAR Date_Ready_to_call =
    CALCULATE (
        MAX ( 'file combine'[date1] ),
        FILTER ( t, [statusLead] = "Ready to call" )
    )
VAR Date_Called =
    CALCULATE (
        MAX ( 'file combine'[date1] ),
        FILTER ( t, [statusLead] = "Called" )
    )
RETURN
    DATEDIFF ( Date_Ready_to_call, Date_Called, DAY )

Icey_0-1634178918883.png

 

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Poo1405
Frequent Visitor

I really appreciate your help; the number shown in the table is very similar to my expectations. Still, I have a problem doing other calculations based on that number (e.g., calculate the average, min, max) to serve statistics on each campaign, source, or calculate KPI for that number under the chart or graph. It didn't work.

From what I observe, the metrics datediff must appear together with the leadid to be displayed. However, I still want it to be a number that can be displayed independently, making it more suitable and easier to represent on the graph or chart.

 

Poo1405_0-1634183187047.png

 

Icey
Community Support
Community Support

Hi @Poo1405 ,

 

For avg, max, etc., try this:

Avg by campaign =
AVERAGEX ( VALUES ( 'file combine'[leadid] ), [DateDiff_Call] )
Max by campaign =
MAXX ( VALUES ( 'file combine'[leadid] ), [DateDiff_Call] )

Icey_1-1634199164451.png

In addition, [Date_Diff] measure is calculated based on date1 of each leadid, if you want to show it independently, what are the implications of the results you expect to display?

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Poo1405
Frequent Visitor

Thank you so much for being so helpful; I intend to use the duration of two dates like a KPI to observe and evaluate the performance and quality of call center, so need it can be shown dependent on multi-view (real to source, campaign, date, ...) to so that can best improve my performance and planning. 

 

Anyway, once again, I want to thank @Icey for supporting me; maybe now the average, min, max index of duration (dateiff) can help me create a dashboard that can enhance overall observation of a sufficient assessment of the quality of the call center. 

Icey
Community Support
Community Support

Hi @Poo1405 ,

 

You are welcome. Glad to be able to help you. Wish you a happy life.😉

 

 

Best Regards,

Icey

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.