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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
P_Allert
Frequent Visitor

Can't get USERELATIONSHIP to work

Hi folks,

 

I have a fact table for Flights (Called 'Flights') and a dimension table containing Airports (Called 'Airports').

  • Each row in 'Flights' represents a single flight, performed on a certain date. It has columns for an Origin Airport (POD) and a Destination Airport (POA). The columns contain numeric AirportIDs.
  • Flights mostly have different POD and POA, however it is also common that a flight has the same airport as POD and POA.
  • The AirportID is also present as a column in the 'Airports' table. It contains unique numeric values.
  • The Airport IDs in the POD-Column and the POA-Column in 'Flights' are n:1 related to the AirportID column in the 'Airport' Table.
  • As the 'Flight' table has two different columns containing an AirportID, the relationships need to be inactive (Only one can be active, but I chose two have them both inactive).
  • Combinations of Airports (POD-POA) are not unique and therefore can appear multiple times in the 'Flights' table.
  • The 'Airport' table also contains a column called IATA. The IATA Code of an Airport is a three-letter text identifier, which is unique.

 

I'd like to create DAX measures (Not a calculated table column), which I can use in a table visual, which allow me to display data from the 'Flights' Table, but showing the IATA Codes of POD and POA instead of the AirportID values.

So basically I'd prefer this:

P_Allert_0-1737733336584.png

Over this:

P_Allert_1-1737733378528.png

 

I managed to do this with as calculated columns like below, but would prefer explicit DAX measures, which I can use with more flexibility.

 

POD IATA =
LOOKUPVALUE(
Airports[IATA],
Airports[AirportID], Flights[POD]
)

 

 

This looked like a promising solution, but produces an error "A table of multiple values was supplied where a single value was expected":

 

POD IATA =
CALCULATE(
VALUES(Airports[IATA]),
USERELATIONSHIP(Flights[POD], Airports[AirportID])
)

 

 

I have been searching the web for hours now for clues on what I did wrong here, but am probably asking Google the wrong questions.

 

Can anyone help me out with this?

Thanks.

 

Best regards
Patrick

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@P_Allert 

Please try: 

POD IATA Measure = 
VAR SelectedPOD = SELECTEDVALUE(Flights[POD])
RETURN 
    MAXX(
        FILTER(
            Airports,
            Airports[AirportID] = SelectedPOD
        ),
        Airports[IATA]
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

4 REPLIES 4
Fowmy
Super User
Super User

@P_Allert 

Please try: 

POD IATA Measure = 
VAR SelectedPOD = SELECTEDVALUE(Flights[POD])
RETURN 
    MAXX(
        FILTER(
            Airports,
            Airports[AirportID] = SelectedPOD
        ),
        Airports[IATA]
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi Fowmy,

thanks. It works beautifully. 👍

Best regards

Patrick

Hi @P_Allert 

Did the solutions Fowmy  and Greg_Deckler offered help you solve the problem, if them help, you can accept them as solutions so that more user can refer to. or if you have other problems, you can provide some informaiton so that can offer solutions for you.

 

Best Regards!

Yolo Zhu

Greg_Deckler
Super User
Super User

@P_Allert You need to aggregate your VALUES somehow. Perhaps try to wrap it in a CONCATENATEX.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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