When working with sales and order data, one of the simplest—and most useful—business questions is:
How many days did it take to ship an order?
At first glance, this looks like a straightforward subtraction:
Ship Date − Order Date = Shipping Days
But when you're working in Microsoft Fabric Dataflow Gen2, there is a little more to it than simply subtracting two columns.
The good news is that Dataflow Gen2 uses the familiar Power Query experience, so you can perform this calculation directly during your data transformation process without writing SQL or DAX. Microsoft describes Dataflow Gen2 as a cloud-based data preparation and transformation service built around the Power Query experience.
Let's see how to do it.
The Business Scenario
Imagine we have an orders table containing the following columns as seen in the screenshot below:

The business wants a new column called Shipping Days. This calculation can be performed directly inside the Dataflow Gen2 transformation layer.
Start with Your Dataflow Gen2
Open your Microsoft Fabric workspace and create or open a Dataflow Gen2.
Once you're inside the Power Query editor, bring your orders table into the dataflow.
Dataflow Gen2 allows you to connect to a wide range of data sources and transform the data before loading it into destinations such as a Lakehouse or Warehouse.
The first thing I would check is the data type of both date columns.
Make Sure Both Columns Are Actually Dates
This is a small step that can save you from a surprisingly frustrating error.
Select OrderDate and confirm that its data type is Date.
Do the same for ShipDate.
You don't want one column to be Date while the other is Text or Date/Time.
Power Query performs date arithmetic based on compatible date and time types. Microsoft notes that subtracting different date/time types—for example, a date from a datetime—can result in an error unless you explicitly convert the values.
So, before doing the calculation:
OrderDate → Date
ShipDate → Date
As seen in the previous screenshot, the Order Date and the Ship Date columns has date data type
The Simple Solution
Now add a Custom Column.
In the Power Query editor:
Add Column → Custom Column
Give the new column a name:
ShippingDays
Then enter:
[ShipDate] - [OrderDate]

Dataflow Gen2 allows specifying the desired data type before hitting OK. This is not available in Power Query of Power BI and Excel . For this demonstration, the Whole number data type is selected. Then, click OK
That's it.
Power Query subtracts the two dates and produces the result as seen below:

What If Your Columns Are Date/Time?
This is another situation you'll encounter frequently in real projects.
Suppose your data looks like this:
OrderDate = 2026-08-01 10:30:00
ShipDate = 2026-08-03 14:45:00
Subtracting them produces a duration that includes both days and time.
If your requirement is to calculate the exact elapsed time, that's useful.
But if the business question is simply:
"How many calendar days passed between the order and shipping dates?"
you may want to convert both columns to Date first.
For example:
Date.From([ShipDate]) - Date.From([OrderDate])
and then:
Duration.Days(
Date.From([ShipDate]) - Date.From([OrderDate])
)This removes the time component from the calculation.
What About Missing Dates?
Real-world data is rarely perfect.
You might have an order like:
Order ID Order Date Ship Date
Perhaps the order hasn't shipped yet.
If you blindly calculate the difference, you won't get a meaningful shipping duration.
Instead, you can add some business logic.
For example:
if [ShipDate] = null then null
else Duration.Days([ShipDate] - [OrderDate])
This leaves the Shipping Days value blank until the order has actually shipped.
You could also return a label such as "Not Shipped" depending on the reporting requirement.
What If the Ship Date Is Earlier Than the Order Date?
This is another useful data-quality check.
Imagine:
Order Date = 10/08/2026
Ship Date = 08/08/2026
The calculation would produce a negative duration.
Technically, that's valid arithmetic. From a business perspective, however, it probably indicates a data-quality problem.
You could identify such records with:
if [ShipDate] < [OrderDate] then "Invalid Dates"
else "Valid"
Or incorporate the validation directly into your shipping-days calculation.
This is one of the advantages of doing the transformation in Dataflow Gen2: you're not merely calculating a metric; you're also able to clean and validate the data before it reaches downstream reporting.
Why Calculate This in Dataflow Gen2?
You might wonder:
Why not simply calculate Shipping Days in Power BI using DAX?
You certainly can.
But there is a strong architectural argument for performing the calculation during data preparation when the value is fundamentally a property of the source data.
If ShippingDays is required by multiple reports, calculating it once in the dataflow means downstream consumers don't all need to recreate the same logic.
For example:
Source System
↓
Dataflow Gen2
↓
Clean + Transform
↓
ShippingDays
↓
Lakehouse / Warehouse
↓
Power BI Semantic Model
↓
ReportsNow the transformation becomes part of your reusable data pipeline.
A More Production-Ready Example
For a real production dataflow, I might use something like:
if [OrderDate] = null or [ShipDate] = null then
null
else if [ShipDate] < [OrderDate] then
null
else
Duration.Days(
Date.From([ShipDate]) - Date.From([OrderDate])
)This handles three important scenarios:
Missing Order Date
Missing Ship Date
Ship Date earlier than Order Date
Only valid records receive a shipping duration.
You can then create a separate data-quality flag for the invalid records rather than silently hiding them.
Turning the Calculation into a Business KPI
Once you have ShippingDays, you can do much more than display it in a table.
For example, the business could define:
0–2 days → Fast
3–5 days → Standard
6+ days → Delayed
That allows Power BI to answer questions such as:
What is our average shipping time?
Which customers experience the longest delays?
Which products take the longest to ship?
Which warehouses are performing poorly?
What percentage of orders ship within two days?
Has shipping performance improved over time?
A simple date subtraction has now become a useful operational metric.
The Bigger Fabric Lesson
This small example demonstrates an important principle in Microsoft Fabric:
Transform data as close to the data-engineering layer as practical.
Dataflow Gen2 gives you a low-code environment for ingestion and transformation using Power Query, while allowing the resulting data to be loaded into Fabric destinations for downstream analytics.
Instead of repeatedly calculating the same business logic inside individual Power BI reports, you can create a reusable transformation once and make the resulting column available to multiple consumers.
And because Dataflow Gen2 is part of the broader Fabric ecosystem, the transformation can become one stage of a much larger data platform.
In conclusion, calculating the number of days between Order Date and Ship Date in Dataflow Gen2 is straightforward once you understand how Power Query handles dates.
The key expression is:
Duration.Days([ShipDate] - [OrderDate])
But the real lesson goes beyond the formula.
Always check your data types, handle missing values, validate unexpected dates, and decide whether the calculation belongs in the transformation layer or the semantic model.
Sometimes a two-line Power Query expression is all you need to turn raw operational data into a useful business metric.
And that's one of the things I like about Microsoft Fabric—simple transformations can become reusable building blocks in a much larger analytics architecture.