Forum Discussion

Amine008's avatar
Amine008
Frequent Visitor
4 years ago

DateDiff from same column with condition in Power BI

Hi All, I am having one table in PowerBI which is having 2 columns: 1.EnrollId 2.StatusChangeDate.  I want to find no. of days between two dates with status condition and excluding weekends. Saturday and Sunday ! 

EnrollId  StatusChangeDate
19650576/16/2020 8:36
19650577/3/2020 8:34
19650577/3/2020 8:52
19650577/3/2020 10:20

 

Current formula works fine but not sure how to exclude weekends. 

 

DaysLastChange = 
VAR _currentStatusChangeDate = [StatusChangeDate]
VAR _currentEnrollId = [EnrollId]
RETURN
    DATEDIFF(
        CALCULATE(MAX('Table1'[StatusChangeDate]);FILTER('Table1';_currentEnrollId = [EnrollId] && _currentStatusChangeDate > [StatusChangeDate] ));
        _currentStatusChangeDate;
        DAY
    )

any help please ?  

 

4 Replies

  • Amine008 I added the link to download pbix file in the description of the video.

     

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

  • Amine008 here is one video which I did on working dates, you can tweak and learn from here and implement in your solution. How to calculate shipping date based on the working date ignore non working days - Power BI - YouTube

     

     

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

     

     

    • Amine008's avatar
      Amine008
      Frequent Visitor

      Thanks parry2k for reaching out. 
      Would you please share sample of Pbix file used in this video ? 
      I am having error while trying to duplicate the steps : Unexpected value for ORDER argument in RANKX function. Use 0/FALSE/DESC for descending order or 1/TRUE/ASC for ascending order.
      Thanks
      Amine