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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
SN1900
Frequent Visitor

IF Formular ( 2 Tables)

Hi all, 

 

Actually I am starting to create my first Power BI Reports and therefore I need an if formular. 

Unfortunately it is not working as I can only select the data from one of the two tables.

 

Let me shortly explain what I want to do. 

 

I have two tables. 

In both tables is one column with a time which I need for my formular as I want to compare both times.

 

I created the formular already in excel and there it is working. 

 

If(Table1[Time1]-Table2[Time2]>=0;Text(Time1[Time1]-Table2[Time2];"[hh]:mm");TEXT(-(Table1[Time1]-Table2[Time2]);"-[hh]:mm"))

 

The formular should compare the both times and show me the difference. 

I used the formular text because otherwise Excel can not create "negative time"

 

The formular is working in Power BI as well but only if the two times are in the same table. 

 

My only question is how I can create this formular in PowerBI  by using different tables.

 

Thanks in advance and best regards 

 

Niclas 

 

 

 

2 REPLIES 2
Anonymous
Not applicable

With the info you've given it's not possible to tell you what to do. We have to know the structure of your model first of all...

Best
D.

Hi darlove, 

 

please find attached some screenshoots

 

So what I wanted to do is to compare the event date with the delivery appointment time. 

The relationship for both tables is the Shipment ID. 

 

The Shipment ID and the Delivery Appointment Time is coming from the table OTM Shipment analysis. 

The Event time is coming from the OTM Event analysis.

 

I tried the formular with time values from one table and then it is working.

(IF(OTM_EventStatus_Analysis[EVENT DATE TIME UTC]-OTM_EventStatus_Analysis[EVENT DATE TIME]>=0;FORMAT(OTM_EventStatus_Analysis[EVENT DATE TIME UTC]-OTM_EventStatus_Analysis[EVENT DATE TIME];"hh:mm:ss");FORMAT(-(OTM_EventStatus_Analysis[EVENT DATE TIME UTC]-OTM_EventStatus_Analysis[EVENT DATE TIME]);"-hh:mm:ss")))
 
But now I want to replace the "Event date time utc "with the "delivery Appointment time" but this is not working as the Delivery Appointment time is in another table. 

 

 

dataset.PNGrelationship.PNGtable.PNG

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.