I am a new PowerBi user and I would like to create a primary/foreign key relationship using a DAX formula which will return the id of the corresponding line to me.
I have two tables:
- CompanyXFlights
- GlobalFlights
The dax formula:
Exist =
COALESCE (
CALCULATE (
COUNTROWS ( CompanyXFlights );
FILTER (
CompanyXFlights;
OR (
AND (
GlobalFlights[ArrivalDateTime]
< CompanyXFlights[DateTime] + TIME ( 0; 10; 0 );
GlobalFlights[ArrivalDateTime]
> CompanyXFlights[DateTime] - TIME ( 0; 10; 0 )
);
AND (
GlobalFlights[DepratureDateTime]
< CompanyXFlights[DateTime] + TIME ( 0; 10; 0 );
GlobalFlights[DepratureDateTime]
> CompanyXFlights[DateTime] - TIME ( 0; 10; 0 )
)
)
&& GlobalFlights[AircraftRegistrationCode]
= CompanyXFlights[AircraftRegistrationCode]
)
);
0
)
I'm using this formula to get the number of corresponding lines, but now I want it to return the index (id) of the line. What should I change? Should I put CompanyXFlights[Id]
instead of COUNTROWS(CompanyXFlights)
or should I use another formula?