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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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