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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
gwizzer
New Member

Append Query (does not work when primary query is empty)

I have two queries which may or may not return rows.  However, if the primary query is empty then when a refresh is issued there is an error 

Column 'anycolumn' in Table 'primaryTable' contains blank values and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table.

 

Do you have to create a temporary record ... or is there another method of appending ?

 

5 REPLIES 5
Eric_Zhang
Microsoft Employee
Microsoft Employee


@gwizzer wrote:

I have two queries which may or may not return rows.  However, if the primary query is empty then when a refresh is issued there is an error 

Column 'anycolumn' in Table 'primaryTable' contains blank values and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table.

 

Do you have to create a temporary record ... or is there another method of appending ?

 


@gwizzer

 

Based on my test, that error occurs when there exists null values in the "one" table's related column(s).

Capture.PNG

Capture.PNG

 

A solution can be filtering out the null values in "one" table or replacing null with other value.


Capture.PNG

 

I don't find this error has anything specific to do with "primary query in apend query return no row". Could you elaborate more details?

 

If you have any question, feel free to let me know

HI Eric,

No Table 1 has no NULL records ... just create the table.  The requirement is that I am appending two task tables into a single view, however, it will happen that either may be blank ... for sure if a record is returned then the ID will not be blank.  I have not tested waht you describe below, and the issue only happens when either table is blank

@gwizzer

 

Can you post a picture of the appended query result and the relationships correlated to the table "PrimaryTable" in your case?

I am getting the same exception while appending two tables.

 

Column 'column 2' in Table 'Current table' contains blank values and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table.

 

I have made sure that there are no null on primary columns but there are column which has null in current table. I do not understand why does that impact in append ?

 

Please help me understand this issue. 

ImkeF
Community Champion
Community Champion

you can perform "sort of" conditional code branching like described here: http://community.powerbi.com/t5/Community-Blog/Conditional-Code-Branching-in-Power-BI-Query-if-then-...

 

Just wrap your existing appdend-step into sth like this:

 

AppendStep = try Table.Combine({Table1, Table2}) otherwise Table2

 

We're not using "if-then-else" here, because we have to deal with an error message. Therefore: "try-otherwise"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.