Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Calculate date difference for the projects which has tasks condition

Hi All,

Need help with calculating date difference for the projects which has only tasks "Enquiry Submitted" and "Approval Sent"

"Approval sent" should consider start date and "enquiry submitted "task should consider End date.
amitchandak 

Jihwan_Kim 
dax 

 

ProjectTaskStart Dateend date
AC1Enquiry Submitted12-06-202209-06-2022
AC1Approval Sent19-06-202212-06-2022
AC2Enquiry Submitted05-06-202209-06-2022
AC3Enquiry Submitted04-06-202205-06-2022
AC4Enquiry Submitted1-06-202205-06-2022
AC4Approval Sent02-06-202201-07-2022
AC4Feedback submitted04-06-202209-06-2022
AC6Enquiry Submitted11-09-202221-06-2022
AC6Approval Sent21-06-202222-06-2022

 

Expected o/p:
Projects AC1 and AC6 to be considered
Ac1 date diff 19-06-2022 minus 09-06-2022 =10days
Ac6 date diff 21-06-2022 minus 21-06-2022 = 0day

  • Hi,

    Thank you for your feedback.

    Do you mean that the card visualization shows 5 as a result?

    Please check the below meausre and the attached pbix file.

     

    Expected avg measure: = 
    AVERAGEX(VALUES(Data[Project]), [Date diff by condition measure:])

     

     

3 Replies

  • Hi,

    Please check the below picture and the attached pbix file.

    It is for creating a measure.

     

     

    Date diff by condition measure: =
    VAR _conditionone =
        COUNTROWS (
            FILTER ( Data, Data[Task] IN { "Enquiry Submitted", "Approval Sent" } )
        ) = 2
    VAR _conditiontwo =
        COUNTROWS ( VALUES ( Data[Task] ) ) = 2
    RETURN
        DATEDIFF (
            CALCULATE ( MAX ( Data[end date] ), Data[Task] = "Enquiry Submitted" ),
            CALCULATE ( MAX ( Data[Start Date] ), Data[Task] = "Approval Sent" ),
            DAY
        )
            * DIVIDE ( _conditionone, _conditiontwo )
    
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Jihwan_Kim ,

       

      Thank you for the response.It is working when I drag the project and "date diff by condition measure" into a table.

      Is there a way to show the average of all these datediffs in a single card.

       

      Thanks

      • Jihwan_Kim's avatar
        Jihwan_Kim
        Icon for Super User rankSuper User

        Hi,

        Thank you for your feedback.

        Do you mean that the card visualization shows 5 as a result?

        Please check the below meausre and the attached pbix file.

         

        Expected avg measure: = 
        AVERAGEX(VALUES(Data[Project]), [Date diff by condition measure:])