The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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.
Solved! Go to Solution.
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
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
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.
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
User | Count |
---|---|
68 | |
63 | |
59 | |
54 | |
28 |
User | Count |
---|---|
183 | |
80 | |
62 | |
46 | |
38 |