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
idage
Helper I
Helper I

RELATIONS IN POWER BI

Dear All, i need your help to understand...

I have to tables (simple tables):

TAB A

 

NOMECITTA
CARLOTTAPISA
FEDERICAFIRENZE
MIMMONAPOLI
PIERONAPOLI
MARCOMILANO

 

TAB B

 

NOMESCUOLA
IDADINI
CARLOTTAFIBONACCI
SALVATOREFERMI
FEDERICAFERMI
MIMMODINI
GIOVANNIBUONARROTI

 

I would like to realize a table like this:

 

NOMECITTASCUOLA
CARLOTTAPISAFIBONACCI
FEDERICAFIRENZEFERMI
MIMMONAPOLIDINI
PIERONAPOLI 
MARCOMILANO 
IDA DINI
SALVATORE FERMI
GIOVANNI BUONARROTI

 

Is it possible? How?

 

Thank you very much for your help.

 

 

 

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

vicky__1-1693522406333.png

Hey, 
If you have access to Power Query, you can use Merge Queries, and use Full Outer Type. 

vicky__2-1693522442523.png

The result should be something like the above. To get the NOME column to look like your result, you can use a query like: Table.AddColumn(#"Expanded Tab B", "NOME (Keep)", each if [NOME] = null then [NOME.1] else [NOME]) in PowerQuery to a column without null in the NOME column.

 

If you want to do so in DAX, try something like:

MergedTable = ADDCOLUMNS(
    DISTINCT(
        UNION(SELECTCOLUMNS('Tab A', "NOME", 'Tab A'[NOME]), SELECTCOLUMNS('Tab B', "NOME",('Tab B'[NOME])))
    ),
    "Citta", CALCULATE(MAX('Tab A'[CITTA]), 'Tab A'[NOME] = EARLIER([NOME])), 
    "Scuola", CALCULATE(MAX('Tab B'[SCUOLA]), 'Tab B'[NOME] = EARLIER([NOME]))
)

View solution in original post

3 REPLIES 3
vicky_
Super User
Super User

vicky__1-1693522406333.png

Hey, 
If you have access to Power Query, you can use Merge Queries, and use Full Outer Type. 

vicky__2-1693522442523.png

The result should be something like the above. To get the NOME column to look like your result, you can use a query like: Table.AddColumn(#"Expanded Tab B", "NOME (Keep)", each if [NOME] = null then [NOME.1] else [NOME]) in PowerQuery to a column without null in the NOME column.

 

If you want to do so in DAX, try something like:

MergedTable = ADDCOLUMNS(
    DISTINCT(
        UNION(SELECTCOLUMNS('Tab A', "NOME", 'Tab A'[NOME]), SELECTCOLUMNS('Tab B', "NOME",('Tab B'[NOME])))
    ),
    "Citta", CALCULATE(MAX('Tab A'[CITTA]), 'Tab A'[NOME] = EARLIER([NOME])), 
    "Scuola", CALCULATE(MAX('Tab B'[SCUOLA]), 'Tab B'[NOME] = EARLIER([NOME]))
)

Thank you very much for your wonderful help!

Thank you very much for your reply but i need to show all names in the first column.  That could be possible managing relationship in power bi?

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.