Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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 only have one create and close in table to have correct calculation. Please see table 3 for what i need:

 

WHat i started with:

table 1

IDClosedCreatedDuration
105/09/201914/09/20199
207/09/201915/09/20198
310/09/201913/09/20193
108/09/201915/09/20197
208/09/201914/09/20196
105/09/201913/09/20198
402/09/201914/09/201912

 

Then i managed to create:

table 3

IDClosedCreatedDurationEarliestOldestDuration per case
105/09/201914/09/2019905/09/201915/09/201910
207/09/201915/09/2019807/09/201915/09/20198
310/09/201913/09/2019310/09/201913/09/20193
108/09/201915/09/2019705/09/201915/09/201910
208/09/201914/09/2019607/09/201915/09/20198
105/09/201913/09/2019805/09/201915/09/201910
402/09/201914/09/20191202/09/201913/09/201911

 

And then i already cteated new table with unique values (using VALUES()). Not sure if this is the best way, but the one i have so far. What i need in the end is:

table 3

 

IDEarliestOldestDuration per case
105/09/201915/09/201910
207/09/201915/09/20198
310/09/201913/09/20193
402/09/201913/09/201911

 

So my Average is 8 insteaed 8.7

 

Please help with methodology

Regards

Filarap

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

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”.

Creating unique values table with min_max timestamps 1.PNG

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]
)

Creating unique values table with min_max timestamps 2.PNG

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.

 

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Is this problem sloved?
 
If it is sloved, could you kindly accept it as a solution to close this case?  
 
If not, please let me know.  
 
Best Regards
Icey
Anonymous
Not applicable

Hi Icey,

 

Apologies, thought already did.

 

Thank you very much for your help, i managed to solve with with your suggestions

 

Regards

Filarap

Icey
Community Support
Community Support

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”.

Creating unique values table with min_max timestamps 1.PNG

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]
)

Creating unique values table with min_max timestamps 2.PNG

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.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.