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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
janinedev
Frequent Visitor

DAX Query Error: Mismatched Number of Columns (UNION)

 

Hello all,

I'm currently grappling with an issue related to a DAX query, and I'm reaching out to seek your expertise in resolving it. Whenever I attempt to execute a DAX query with a UNION, I encounter an error message that states "Mismatched Number of Columns." I'm at a bit of a loss as to where I might be making a mistake, so I'm hoping for some valuable guidance and insights from this community.

Description:

I'm in a situation where I'm trying to amalgamate data from multiple tables using a DAX query that includes a UNION operation. The goal here is to create a unified result set, combining data from these different tables. However, it appears that my DAX query is faltering due to an expectation of the same number of columns in all the SELECT statements within the UNION.

I've rigorously reviewed the structure of my tables and the individual SELECT statements, and everything seems to be in order. Despite my efforts, the error persists.


attached below are the screenshot of my query.

janinedev_0-1697190498678.png

janinedev_1-1697190541170.png

janinedev_2-1697190605706.png

 

 

2 ACCEPTED SOLUTIONS
HotChilli
Super User
Super User

ADDCOLUMNS returns a table.  These 2 columns : source and count, get added to each of the tables: vw_booking_ref and vw_request.

Then there is an attempt to UNION the 2 tables.That means the whole of each table not just the 2 columns mentioned

 

  • The two tables must have the same number of columns.

  • Columns are combined by position in their respective tables.

 

Does that help?

View solution in original post

Hello, Sir @HotChilli @. I wanted to express my gratitude for your valuable feedback. 

I made some adjustments to my query to achieve the desired result

janinedev_0-1698039246875.png

 



View solution in original post

4 REPLIES 4
HotChilli
Super User
Super User

ADDCOLUMNS returns a table.  These 2 columns : source and count, get added to each of the tables: vw_booking_ref and vw_request.

Then there is an attempt to UNION the 2 tables.That means the whole of each table not just the 2 columns mentioned

 

  • The two tables must have the same number of columns.

  • Columns are combined by position in their respective tables.

 

Does that help?

Hello, Sir @HotChilli @. I wanted to express my gratitude for your valuable feedback. 

I made some adjustments to my query to achieve the desired result

janinedev_0-1698039246875.png

 



janinedev
Frequent Visitor

Good day, @HotChilli. I appreciate your time and assistance

I apologize for any prior lack of information. I'd like to provide you with the table structure for both 'vw_request' and 'vw_booking_ref':

Additionally, I have a question regarding the difference in the number of columns between these two tables. As I mentioned in my previous post, I shared the query for the union, where I selected only two columns for both queries. Does this difference in column count matter? Your insights on this would be greatly appreciated.


 

janinedev_1-1697702329005.png

 

janinedev_0-1697702300356.png

 

HotChilli
Super User
Super User

What is the structure of the 2 source tables? vw_booking_ref and vw_request

 

--

There might still be a problem but we don't have enough info here

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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