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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
akay23
Helper I
Helper I

Create a Crossjoin Table with boolean condition

Hi all,

 

I have a flight list table that it has 700k rows.

I want to find all possible connections within 12 hours. That's why I tried to crossjoin formula with conditions like;


Filter(
Crossjoin(
 Selectcolumns(
  Data,
   "Carrier1", Data[Carrier Code],
   "Dep1", Data[Dep Airport],
   "Arr1, Data[Arr Airport],
   "ArrTime",Data[Arr Time]),
 Selectcolumns(
  Data,
   "Carrier2", Data[Carrier Code],
   "Dep2", Data[Dep Airport],
   "Arr2, Data[Arr Airport],
   "DepTime",Data[Dep Time])),
[carrier1] = [carrier2] && [Arr1] = [Dep2] && [DepTime] - [ArrTime] < 0.5 &&  0 < [DepTime] - [ArrTime])

But filter uses row context and I think thats why this calculation is so long. My computer can not handle this calculation.

Can it be a calculatetable or boolean solution for this problem? 
I think I have to crossjoin to rows after filtering. How can I do that?

Thank you.
  

2 REPLIES 2
akay23
Helper I
Helper I

Sorry, you are right. This list is my sample data. 

 

 

Flight NoCarrier CodeKeyDep AirportArr AirportDep TimeArr TimeWeekday
1AADXBJEDDXBJED5:056:00Monday
2AAJEDCAIJEDCAI8:0510:30Monday
3AAJEDLHRJEDLHR11:0513:00Monday
4AAJEDDXBJEDDXB15:0517:00Monday

 

And, I want this table to find connection time at the hub (Arr Airport1 & Dep Airport2).
I have conditions;
Two Carrier codes must be same,
Arr Airport Code1 and Dep Airport Code2 must be same (Thats why I called hub),
Dep Time2 is bigger than Arr Time1 and the difference between two is smaller than 12 hours.

Like this table;

 

Flight No1Carrier Code1Key1Dep Airport1Arr Airport1Dep Time1Arr Time1Weekday1Flight No1Carrier Code2 Key2Dep Airport2Arr Airport2Dep Time2Arr Time2Weekday
1AADXBJEDDXBJED5:056:00Monday2AAJEDCAIJEDCAI8:0510:30Monday
1AADXBJEDDXBJED5:056:00Monday3AAJEDLHRJEDLHR11:0513:00Monday
1AADXBJEDDXBJED5:056:00Monday4AAJEDDXBJEDDXB15:0517:00Monday
2AAJEDCAIJEDCAI8:0510:30Monday5AADXBJEDCAIJED5:056:00Monday
2.............. 
                


This is the problem.
My first table has 700k rows. So when I cartesian table with this code,

Filter(

Crossjoin(
 Selectcolumns(
  Data,
   "Carrier1", Data[Carrier Code],
   "Dep1", Data[Dep Airport],
   "Arr1, Data[Arr Airport],
   "ArrTime",Data[Arr Time]),
 Selectcolumns(
  Data,
   "Carrier2", Data[Carrier Code],
   "Dep2", Data[Dep Airport],
   "Arr2, Data[Arr Airport],
   "DepTime",Data[Dep Time])),
[carrier1] = [carrier2] && [Arr1] = [Dep2] && [DepTime] - [ArrTime] < 0.5 &&  0 < [DepTime] - [ArrTime])

This is so slow.
Is there any possibility to rewrite this code using calculatetable or smth. Because if my conditions filtered before crossjoin I think it can be fast.
Thank you 

vanessafvg
Super User
Super User

can you please give some sample data, even if not real data and give what you expect the solution to be?

 

are you saying you want to know every flight in the sky in within 12 hours of a flight?  

 

if you are able to provide

 

1, sample data with expected solution then it is very easy to work it out for you.   This doesn't look like the best to do to this, you are better to model yoru tables more effectively, and do the calcation a very different way, as i am not sure those will work, but first one needs to understand the rule in your data that the data must adhere to, and how you have your model set up.  then it would be easier to figure out how to model this solution  The answer is in how you model your data.

 

can you provide some sample data or your pbix?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.