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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

datediff between first and lastdate

Hi,

 

I need a measure to calculate the time between the first and last delivery date per Purchase order

 

The table is such as:

 

ReceivedorderlinePurchase orderReceivedate
111-1-2017
2115-1-2017
3117-1-2017
422-2-2017
523-2-2017
623-2-2017
733-3-2017
833-3-2017

 

Now i want the time between the first and last receivedate per purchase order

(example purchase order 1. first date = 01-01-2017 and lastdate = 17-1-2017. Measure datediff = 16 days

 

greetings, Norbertus

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@Anonymous

 

hi, Use a measure 

 

DaysDiff = DATEDIFF(Min(Table1[Receivedate]),MAX(Table1[Receivedate]),DAY)

 

Now Put in a visual the PO and this Measure.

 

 

 




Lima - Peru

View solution in original post

3 REPLIES 3
Vvelarde
Community Champion
Community Champion

@Anonymous

 

hi, Use a measure 

 

DaysDiff = DATEDIFF(Min(Table1[Receivedate]),MAX(Table1[Receivedate]),DAY)

 

Now Put in a visual the PO and this Measure.

 

 

 




Lima - Peru
EvertonPessoa
Helper I
Helper I

Hi @Anonymous,

An alternative is to create a new table using dax Summarize: If you do not know: To create a new table go to the tab: modeling>
New Table

 

Dax to create the table:

 

Table2 = SUMMARIZE(Table1; 
		   Table1[Purchase order]; 
		   "MinDate"; MIN(Table1[Receivedate]);
		   "MaxDate";MAX(Table1[Receivedate]); 
	           "Total"; MAX(Table1[Receivedate]) - MIN(Table1[Receivedate])
		   )
Anonymous
Not applicable

Hi,

 

Is it really necessary to create a new table? After this i think my Datamodel isn't 'nice' anymore

Because i merged before receivedorders and receivedorderlines to one new table (as a fact table)

 

When i make 2 seperate tables i can also make a calculated column in receivedorders like:

Column  = CALCULATE((MAX(receivedorderlines[Receivedate])-MIN(receivedorderlines[Receivedate])*1);

FILTER(receivedorderlines;receivedorderlines[order]=receivedorder[order]))

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors