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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Pamdelorbe
Frequent Visitor

Time calculation with DAX or conditional column

Hi everyone!

 

I would like to obtain CTA time based on the carrier's subtraction time frame.

For example, if the carrier is Jet Blue, subtract 75 minutes or (1 h 15 mm) to the specified time.

11:28 AM - 1:15 (or 75 minutes) = 10:13 AM.

 

Pamdelorbe_0-1677695679762.png

 

Please see above the time frame for each carrier. Not sure is the solution should be a calculated column or metric.

 

Thanks in advance for your help!! 

 

 

2 ACCEPTED SOLUTIONS

It try it with a calculated table (not in Power Query Editor), it works with time and datetime:

Column = if('Table'[Carrier]="JET BLUE",'Table'[time]-'Table'[time frame])




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

In my example 
Column = if('Table'[Carrier]="JET BLUE",'Table'[time]-'Table'[time frame])
both time.
I do not understand your question 🙂 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

13 REPLIES 13
andhiii079845
Solution Sage
Solution Sage

Please post some example data with the table function, no screenshot please





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi, 

Let me show you:

1. I try to create a conditional column. For example. if Carrier = Jet Blue, Time Frame = 75 (minutes). 

Pamdelorbe_0-1677699225856.png

Then created a custom colum to subtract time_frame from real time (Hora ATD):

 

Pamdelorbe_1-1677699394384.png

 

Here is the Error: 

 

Pamdelorbe_2-1677699605295.png

 

I think might be the data type I selected for time_frame. 

Please let me know iyour comments. 

Thanks, 

 

 

2. Then I tried to subtract the time frame from Time column. But the result is the time itself and not the subtracted calculated time. 

 

 

Then 

Hora ATD is a real time or and you want to subtract hours from it? This is not possible. You need something like this:
https://community.powerbi.com/t5/Desktop/How-to-add-hours-to-DateTime-data/td-p/104443





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Yes. Hora ATD is a real time and depending the carrier I would like to subtract 90, 75 or 30 minutes in order to obtain a new colum with the subtracted exact time.  

 

Thanks, 

It try it with a calculated table (not in Power Query Editor), it works with time and datetime:

Column = if('Table'[Carrier]="JET BLUE",'Table'[time]-'Table'[time frame])




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi,

One more question:

What format time frame should be? as "time" for example 1:15 AM (1 hour and 15 minutes) or  75 minutes (duration). 

This is to the formula be able to do the calculation between the two columns and not show error. 

In my example 
Column = if('Table'[Carrier]="JET BLUE",'Table'[time]-'Table'[time frame])
both time.
I do not understand your question 🙂 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi, 

 

I think it worked!

Pamdelorbe_0-1677704413766.png

 

Just one more question: How can add multiple carriers to the same formula and also.. 

If else statement?

 

For example...

 

Column = if('Table'[Carrier]="JET BLUE" and IBERIA and CONDOR,'Table'[time]-'Table'[time frame])...

 

Thanks!

 

Yes like this: 

Column = if('Table'[Carrier] in {"JET BLUE, "Test"},'Table'[time]-'Table'[time frame])




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hora ATD has the datatype "datetime", right? Or "time"?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




HI, 

Only time (see below). 

Pamdelorbe_0-1677701374711.png

 

 

I have a doubt about this formula:

[DateTime] + #duration(0,10,0,0))

 

Since time frame relies on a conditional statement (carrier). How can I specify time frame based on the carrier?

 

Thanks, 

andhiii079845
Solution Sage
Solution Sage

It depands if you can do this calculation in the underlaying data. Because it is fix to the columns. You can use calculated columns. If you need to modify it while filtering "on the fly" than use DAX.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Would you please show me both ways? 

 

I try to create a calculated column but only got ERROR.

 

Thanks, 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.