Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi All,
I have a dataset, that contains numerous columns of data, but main ones are:
Columns:
Branch
Status
Despatch Date
Requested Date
Promised Date
I want to calculate the difference in days between the Despatch Date & the advised date.. So the logic needs to be like below.
If Branch="York" & Status = "Out" (so i need both these to be satasified before it determins the true/false.
If True = Despatch Date.Days - Requested Date.Days
If False = Despatch Date.Days - Promised Date.Days
Any assistance would be apprecaited.
Solved! Go to Solution.
@Craig_01 , Try using below formula for new calculated column
Difference =
IF('Table'[Branch] = "York" && 'Table'[Status] = "Out",
DATEDIFF('Table'[Despatch Date], 'Table'[Requested Date], DAY),
DATEDIFF('Table'[Despatch Date], 'Table'[Promised Date], DAY)
)
Proud to be a Super User! |
|
Thanks for the reply from @bhanu_gautam , please allow me to provide another insight:
Hi @Craig_01 ,
Here are the steps you can follow:
1. Add Column – Custom Column.
2. Enter code.
if [Branch]="Your" and [Status] ="Out"
then Duration.Days([Despatch Date] - [Requested Date])
else Duration.Days([Despatch Date] - [Promised Date])
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks for the reply from @bhanu_gautam , please allow me to provide another insight:
Hi @Craig_01 ,
Here are the steps you can follow:
1. Add Column – Custom Column.
2. Enter code.
if [Branch]="Your" and [Status] ="Out"
then Duration.Days([Despatch Date] - [Requested Date])
else Duration.Days([Despatch Date] - [Promised Date])
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks, how to i exclude any Errors, where there is no data to calculate becasue of potentially columns that are only caputring data from 2024, and not in 2023 for example.
@Craig_01 , Try using below formula for new calculated column
Difference =
IF('Table'[Branch] = "York" && 'Table'[Status] = "Out",
DATEDIFF('Table'[Despatch Date], 'Table'[Requested Date], DAY),
DATEDIFF('Table'[Despatch Date], 'Table'[Promised Date], DAY)
)
Proud to be a Super User! |
|
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |