Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Creating unique values table with min / max timestamps

Hi all,   I am strugling to create calculation based on unique values from a table. I need to calculate average duration using only unique ID taking earliest and oldest timestamps.  One ID should...
  • Icey's avatar
    7 years ago

    Hi Anonymous ,

    1. You can create measures like so:

    Earliest = CALCULATE(MIN('Table 1'[Closed]),ALLEXCEPT('Table 1','Table 1'[ID]))
    Oldest = CALCULATE(MAX('Table 1'[Created]),ALLEXCEPT('Table 1','Table 1'[ID]))
    Duration per case = DATEDIFF([Earliest],[Oldest],DAY)

    2. Copy “Visual” and remove “Closed” and “Created”, ”Duration” columns, then you will get “Visual 2”.

    3. Or, you can create a new table.

    Table 3 =
    ADDCOLUMNS (
        VALUES ( 'Table 1'[ID] ),
        "Earliest", [Earliest],
        "Oldest", [Oldest],
        "Duration per case", [Duration per case]
    )

    This is my PBIX file.

     

    Best Regards,

    Icey

     

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