Forum Discussion
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
- ImkeFCommunity 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-else-gt/ba-p/39998
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"
- Eric_ZhangMicrosoft 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 ?
Based on my test, that error occurs when there exists null values in the "one" table's related column(s).
A solution can be filtering out the null values in "one" table or replacing null with other value.
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
- gwizzerNew Member
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
- Eric_ZhangMicrosoft Employee
Can you post a picture of the appended query result and the relationships correlated to the table "PrimaryTable" in your case?