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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
U156531
Helper V
Helper V

Problem with union (selectcolumns

Tablemeasure = Union(
selectcolumns(Table A,"Opening_Date", Table A[Opening_Date]), 
selectcolumns(Table B,"Business_Date", Table B[Business_Date]), 
)

I created a measure using this format above but when I try to put it into a visual I get the error below. Anyone have an idea of what I might be doing wrong?

U156531_0-1709066110752.png

 

1 ACCEPTED SOLUTION
AmiraBedh
Super User
Super User

If you need a list of dates for a visual, create a calculated table instead of a measure :

CombinedDatesTable = UNION(
    SELECTCOLUMNS(TableA, "Date", TableA[Opening_Date]),
    SELECTCOLUMNS(TableB, "Date", TableB[Business_Date])
)

then for the measure : 

UniqueDateCount = DISTINCTCOUNT(UNION(SELECTCOLUMNS(TableA, "Date", TableA[Opening_Date]), SELECTCOLUMNS(TableB, "Date", TableB[Business_Date])))

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

4 REPLIES 4
AmiraBedh
Super User
Super User

If you need a list of dates for a visual, create a calculated table instead of a measure :

CombinedDatesTable = UNION(
    SELECTCOLUMNS(TableA, "Date", TableA[Opening_Date]),
    SELECTCOLUMNS(TableB, "Date", TableB[Business_Date])
)

then for the measure : 

UniqueDateCount = DISTINCTCOUNT(UNION(SELECTCOLUMNS(TableA, "Date", TableA[Opening_Date]), SELECTCOLUMNS(TableB, "Date", TableB[Business_Date])))

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

This is what I created but I'm only getting the Material column in the resulting table?

TableUnion = union(selectcolumns('material class',"Material", [Material Class]),selectcolumns('merge1',"Quantity", [Quantity Received for Current Year]), selectcolumns('material_class' ,"Material", [MATERIAL CLASS]  ) ,  selectcolumns('RFID/Barcode Defective Material Submittals' ,"Quantity", [quantity]  ) )

 

Can you please share your pbix file ?


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Your solution worked, I just had to tweek it a bit for my situation. I accepted your solution.

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!

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!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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