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
Anonymous
Not applicable

Combine Colums

Hey @ all.

My current problem is this:

I have 4 different Excel tables, each of which I have created a calculated column from integers. (Valid_CSIS , Valid_Gen 8....)

In the end I want to have all 4 integer columns from these calculated colums in a single table with only one column. ("Valid"

I cannot use the Union function because the 4 source files all have different numbers of columns.

Forum_Bild.png

 

Thank you for your help.

2 REPLIES 2
Greg_Deckler
Super User
Super User

Use UNION except use SELECTCOLUMNS inside your UNION so:

 

Table = 

  UNION(

    SELECTCOLUMNS('Table1',"Value",[Value blah blah blah]),

    SELECTCOLUMNS('Table2',"Value",[Value blah blah blah]),

    SELECTCOLUMNS('Table3',"Value",[Value blah blah blah]),

    SELECTCOLUMNS('Table4',"Value",[Value blah blah blah])

  )


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Anonymous ,

You can create common dimension tables across all 4 tables and the create a combined measure and use that in visuals along with common dimensions

 

Measure = sum(Table1[Valid_CSIS])+ sum(Table2[Valid_CSIS])+ sum(Table3[Valid_CSIS])+ sum(Table4[Valid_CSIS])

 

Another way to union is inside union use selectcolumns or summarize

 

examples

Summary = UNION(
SUMMARIZE('Table1','Table1'[Customer],'Table1'[created_date],'Table1'[DA Status],"Sales",sum('Table1'[Sales]),"Invoices",count('Table1'[ID]),"Time",DIVIDE(SUM('Table1'[Ship Time]),1),"Stage"," Ship","Gross",sum('Table1'[inv_amount]),"Net",Sum('Table1'[Net Calc Amount]))
,SUMMARIZE('Table2','Table2'[Customer],'Table1'[created_date],'Table2'[AA Status],"Sales",sum('Table2'[Sales]),"Invoices",count('Table2'[ID]),"Time",DIVIDE(SUM('Table1'[Order Time]),1),"Stage","Order","Gross",sum('Table1'[inv_amount]),"Net",Sum('Table1'[Net Calc Amount]))
)

 

 

union(
selectcolumns(table1,"ColA", table1[Column A],"ColA", table1[Column B],"ColF", table1[Column F]),
selectcolumns(table2,"ColA", table2[Column A],"ColA", table2[Column B],"ColF", table2[Column F])
)

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.