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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Rae2023
Frequent Visitor

Counting between two dates but returns blank and the query won't refresh

I have a problem that requires some help.

I've loaded data from Excel into Power Query and I'm counting the number of records between two dates which is no problem but when there's no records in the date range it returns blank and I get an error.

The rest of my queries won't refresh until one record is entered in the date range.

The error message is:

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

Is there a way to overcome this issue?

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Do as it says - provide unique values without gaps on the one side of the one-to-many relationship.  That's how star/snowflake schemas are supposed to work. You can't have null/blank as keys.

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

Is there a reason that you are trying to solve it in the Query Editor.  Would you be OK with a DAX solution?  if yes, then share some data to work with and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Rae2023
Frequent Visitor

Thank you Ibendlin, I understand that I can't have blank values but where I have filtered values between two dates and there are no records to return, How do I ensure that I don't get an error?

= Table.SelectRows(#"Date Column", each [Merged] >= (#"StartDate") and [Merged] <= (#"EndDate"))

Change the relationship type or break the relationship. 

 

(is this a direct query source with dynamic M parameters?)

Hello Ibendlin,

Yes this is a direct query source with dynamic M parameters.

I'm pretty new to Power BI and the terminology

Well, congratulations - you have reached the bleeding edge.  You have managed to unearth a design flaw.

lbendlin
Super User
Super User

Do as it says - provide unique values without gaps on the one side of the one-to-many relationship.  That's how star/snowflake schemas are supposed to work. You can't have null/blank as keys.

Thanks Ibendlin for your help

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.