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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Cybe
New Member

Columns from multiple sources into a single column of distinct values

Hello,

 

  I have dissimilar data sources with one column of like values, and I'm unsure how to join them;  I may be asking the wrong question in my searches for 'combine', 'summarize', etc.  

 

Source 1

DeviceFirewall StatusIrrelevant Data
COMPUTER1OffApple
COMPUTER2OnOrange
COMPUTER3OnLemon

 

Source 2

Computer NameAntivirus Status
COMPUTER1True
COMPUTER4False

 

Source 3

HostnameInternet FacingOther Data
COMPUTER2Fullynull
COMPUTER3PartiallyYes
COMPUTER5Partiallynull

 

Desired Output (A matrix table)

AllComputersInternet FacingFirewallAntivirus
COMPUTER1nullOffTrue
COMPUTER2FullyOnnull
COMPUTER3PartiallyOnnull
COMPUTER4nullnullFalse
COMPUTER5Partiallynullnull

 

I've tried to achieve this via Merge as New, OUTER JOIN in Transform Data, but the result is multiple 'Computername' type columns.   My situation is similar like the post below - but adapting the UNION solution returns, 'a table of multiple values was supplied where a single value was expected'

 

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Repeating-quot-Key-quot-column-value-in-Calcu...

 

What am I missing?  Any help appreciated!

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Cybe 

you can do this in pq.

pls see the attachment below

1.PNG

you can also use DAX to create a table

 

Table = 
VAR tbl=DISTINCT(UNION(SELECTCOLUMNS('Source 1',"AllComputers",'Source 1'[Device]),SELECTCOLUMNS('Source 2',"Allcomputers",'Source 2'[Computer Name]),SELECTCOLUMNS('Source 3',"Allcomputers",'Source 3'[Hostname])))
return ADDCOLUMNS(tbl,"Internet Facing",maxx(FILTER('Source 3',[AllComputers]='Source 3'[Hostname]),'Source 3'[Internet Facing]),"firewall",maxx(FILTER('Source 1',[AllComputers]='Source 1'[Device]),'Source 1'[Firewall Status]),"Antivirus",maxx(FILTER('Source 2',[AllComputers]='Source 2'[Computer Name]),'Source 2'[Antivirus Status]))

 

2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
Cybe
New Member

Thank you @ryan_mayu, your attachment contained the answer I needed; 
For future searchers, I created a New Source / Blank Query, and input:

 

= Table.FromList( List.Distinct(List.Combine({#"Source 1"[Device],#"Source 2"[Computer Name],#"Source 3"[Hostname]})))

 

This produced a single column of all computers from the three sources. 

Then, merge in each of the original sources (left join on computer name) to produce the desired output.


Thank you @ryan_mayu!  

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

@Cybe 

you can do this in pq.

pls see the attachment below

1.PNG

you can also use DAX to create a table

 

Table = 
VAR tbl=DISTINCT(UNION(SELECTCOLUMNS('Source 1',"AllComputers",'Source 1'[Device]),SELECTCOLUMNS('Source 2',"Allcomputers",'Source 2'[Computer Name]),SELECTCOLUMNS('Source 3',"Allcomputers",'Source 3'[Hostname])))
return ADDCOLUMNS(tbl,"Internet Facing",maxx(FILTER('Source 3',[AllComputers]='Source 3'[Hostname]),'Source 3'[Internet Facing]),"firewall",maxx(FILTER('Source 1',[AllComputers]='Source 1'[Device]),'Source 1'[Firewall Status]),"Antivirus",maxx(FILTER('Source 2',[AllComputers]='Source 2'[Computer Name]),'Source 2'[Antivirus Status]))

 

2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors