Forum Discussion

Marcin's avatar
Marcin
Helper V
8 years ago
Solved

DatediffbyRows

Hi,

 

I am looking for solution to calculate DAYs difference between Process1 date and Process3 date for each project in calculated column. 

 

              Project                                                                                        ProcessDate

ProjectID DiffProcess1andProcess3Days                          ProjectID      ProcessName         Date
    1         |                  ??                                                          1              Process1             05.01.2018
    2         |                  ??                                                          1              Process2             12.01.2018
                                                                                               1              Process3             28.01.2018
                                                                                               2              Process1             04.02.2018
                                                                                               2              Process2             06.02.2018
                                                                                               2              Process3             24.02.2018

 

 

  • Hi Marcin,

     

    Try this measure please.

    Measure =
    VAR p1Date =
        CALCULATE (
            MIN ( 'Table1'[Date] ),
            FILTER (
                ALLEXCEPT ( Table1, 'Table1'[ProjectID] ),
                'Table1'[ProcessName] = "Process1"
            )
        )
    VAR p3Date =
        CALCULATE (
            MIN ( 'Table1'[Date] ),
            FILTER (
                ALLEXCEPT ( 'Table1', Table1[ProjectID] ),
                'Table1'[ProcessName] = "Process3"
            )
        )
    RETURN
        DATEDIFF ( p1Date, p3Date, DAY )
    

    Datediffby_Rows

     

    Best Regards,

    Dale

2 Replies

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi Marcin,

     

    Try this measure please.

    Measure =
    VAR p1Date =
        CALCULATE (
            MIN ( 'Table1'[Date] ),
            FILTER (
                ALLEXCEPT ( Table1, 'Table1'[ProjectID] ),
                'Table1'[ProcessName] = "Process1"
            )
        )
    VAR p3Date =
        CALCULATE (
            MIN ( 'Table1'[Date] ),
            FILTER (
                ALLEXCEPT ( 'Table1', Table1[ProjectID] ),
                'Table1'[ProcessName] = "Process3"
            )
        )
    RETURN
        DATEDIFF ( p1Date, p3Date, DAY )
    

    Datediffby_Rows

     

    Best Regards,

    Dale

    • Marcin's avatar
      Marcin
      Helper V

      Hi,

       

      thanks for help, that work for me, but I had to remove ALLEXCEPT function so that it would work when I used measure in Project column.