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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Most Valuable Professional
Most Valuable Professional

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
Most Valuable Professional
Most Valuable Professional

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]  ) )

 

AmiraBedh
Most Valuable Professional
Most Valuable Professional

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!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.