Forum Discussion

hpatel24779's avatar
hpatel24779
Icon for Helper II rankHelper II
1 year ago

Calculate weeks between step date and calendar

Hi All,

 

I have a dataset of all cases that are pending and i need to identify if the wait weeks are increasing or decreasing each month. I need a measure that works out the longest wait per month and show this in a graph so you can see what the longest wait is by month.

 

Over time data will change as once a case is completed, it will come off the dataset which is fine.

So for example, if i have a case that came in on 14/05/2022, i need to calculate how long this has been waiting for so i would work out number of weeks between 14/05/2022 to 28/02/2025 for latest month but same applies for previous months i.e number of weeks between 14/05/2022 to 31/01/2025, 3/12/2024 etc.

 

is it possible to acheive this? any workaround also helpful.

 

thank you in advance

 

kind regards

 

Hetal

15 Replies

  • rajulshah's avatar
    rajulshah
    Icon for Resident Rockstar rankResident Rockstar

    Hello Hetal, hpatel24779 

     

    Yes, this can surely be possible. But can you please share sample dataset to confirm if it is achievable or not?

    • hpatel24779's avatar
      hpatel24779
      Icon for Helper II rankHelper II

      Hi,

       

      Below is sample data where i have shown the number of weeks for previous 5 months. i need to be able to calculate this over a period of time.

       

      Step IDStep Date28/02/202531/01/202531/12/202430/11/202431/10/2024
      106/11/2021172.9168.9164.4160.0155.7
      228/06/202435.031.026.622.117.9
      314/05/2022145.9141.9137.4133.0128.7
      412/01/20256.72.70.00.00.0
      530/04/202395.791.787.382.978.6

       

      kind regards

       

      Hetal

      • rajulshah's avatar
        rajulshah
        Icon for Resident Rockstar rankResident Rockstar

        Hi hpatel24779 , I would need a raw sample data with few tables you have. You can upload the sample data files to OneDrive and share the link.

  • freginier's avatar
    freginier
    Icon for Solution Sage rankSolution Sage

    Hi there!

     

    If I understand correctly, you want to calculate the number of weeks a case has been pending for each month, and track whether wait times are increasing or decreasing over time.

    First, create a DAX Measure for Weeks Pending:

    Weeks_Pending =
    VAR CaseDate = SELECTEDVALUE( Table[CaseDate] ) -- Get the case start date
    VAR MaxMonthDate = MAX( Calendar[Date] ) -- Get the last date of the selected month
    VAR WeeksBetween = DATEDIFF( CaseDate, MaxMonthDate, WEEK ) -- Calculate weeks difference

    RETURN
    IF( NOT ISBLANK(CaseDate), WeeksBetween )

    (This calculates the number of weeks between the case date and the last date of the selected month.)

     

    Use a Line Chart in Power BI:

    - X-axis: Month (from your Calendar table

    - Y-axis: Weeks_Pending

    - Use MAX(Weeks_Pending) to display the longest wait time for each month.

     

    Hope this helps!

    😁😁

    • hpatel24779's avatar
      hpatel24779
      Icon for Helper II rankHelper II

      Hi freginier 

       

      i have tried this and whilst it does calculate the weeks pending, when plotting into a line graph, i put the month in X-axis and weeks pending in y-axis but no results show.

      also, i am not entirely sure what you meant by 'Use MAX(weeks_pending)'

       

      kind regards

       

      Hetal

  • v-karpurapud's avatar
    v-karpurapud
    Icon for Community Support rankCommunity Support

    Hi hpatel24779 

    Could you please confirm if your query have been resolved the solution provided by rajulshah ? If they have, kindly mark the helpful response and accept it as the solution. This will assist other community members in resolving similar issues more efficiently.

    Thank you

  • v-karpurapud's avatar
    v-karpurapud
    Icon for Community Support rankCommunity Support

    Hi hpatel24779 

    We are following up to see if your query has been resolved. Should you have identified a solution, we kindly request you to share it with the community to assist others facing similar issues.

    If our response was helpful, please mark it as the accepted solution and give a kudos, as this helps other members in  community.



    Thank you

  • v-karpurapud's avatar
    v-karpurapud
    Icon for Community Support rankCommunity Support

    Hi hpatel24779 

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

    Thank you.