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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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