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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Rasmusrock
Helper II
Helper II

Difference between two dates

Hi,


I am looking to make a table that shows me when an order is: on time, arrives before time or is late, and how late or early it is.

 

This is given by two dates: 

 

'Shipment date' minus 'Confirmed date'  -----> ('Afskibning'  'Bekrxftet' in Danish)

 

Right now, i have combined the two calculated columns, and the calculated measure below:

 

Columns:
=[Afskibning]-[BEKRXFTET]

 

=IF([Forskel_afskibning]>1000;BLANK();IF([Forskel_afskibning]<-1000;BLANK();[Forskel_afskibning])) --> To sort out any rows where the date is blank (01-01-1900)

 

Measure:

Positiv leveringsevne=CALCULATE(SUM(Indlinjer[Leveringsevne_afskibning]);Indlinjer[Leveringsevne_afskibning]>0) --> To only give me the order that arrived ahead of the scheduled time

 

Which gives the me below result, where '13296' is the order number, and the below figures are the items in the order.

 

132961196 
Cb0850149 
Cb0851149 
Cb0852149 
Cb0853149 

 

However, using my calculation it sums up how early each item in the order is (49 in this example) which adds up to 196 for the four items. Therefore, i am looking for a way for the formula to not show how early each item is, but only how early (or late) an order is, while still being able to show the items in the order. 

 

Hope someone can help!

 

/Rasmus

3 REPLIES 3

Hi Rasmus,

 

Could you provide more information about your table schemas?

Do you actually have a table with both orders and items on the same column? If so, how do identify that a row is an order and not an item?

 

If the table below is a visual with orders and nested items, you can use HASONEVALUE on your items column (Replace the commas with semicolons for your enviornment):

New Measure for Orders Only = IF ( HASONEVALUE ( <Items Table and Column Name> ) , BLANK() ,  [Positiv leveringsevne] ) 

 

Hope it helps,

Gil

Thanks @DataChant, it partly solves my problem, however not the most essential part of the problem.. Ill try to explain in detail:

 

As you see in the below picture, the left pivot is my current result, and the right result is when i apply your formula. The numbers are the same, however, i am not able to show the items in the orders.

 

 Current situation.PNG

 

What i want is presented in the next picture, where i tried to explain it a bit more detailed:

 

Goal.PNG

 

The left table shows the denotation of the table, with three layers: Creditor, Order and item, and a given order can only be positive or negative (Positive = Early arrival, Negative = Late arrival).

 

The middle table shows my current status, where the "earliness" of the order is given by summing the "earliness" of each item in the order. However, i want it to only sum the amount of time a specific order is early (as shown in table 3), and not how early each item in the order is.

 

Does it make sense?

 

/Rasmus

Hi @Rasmusrock,

 

Could you post your table structures with some sample data, and the measures you are using in this case? It's better to share a sample pbix file.Smiley Happy

 

Regards

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.