Forum Discussion
Power Query - We cannot convert the value null to type Number.
Thanks for your response Pete.
The 'RequiredRows' column is returning 0 when an arrival and departure time is less than 1 hour. I created a conditional column 'RequiredRows1' that if 'RequiredRows' = 0 then return 1. This was done so I could then enter the below M code which adds a row for each hour between arrival and departure time. If I didn't do this the 'Custom' column would return a null for any row less than 1 hour.
I hope this makes sense. Thanks
Hi Lachlanpap ,
How have you identified this part of your code as the problem? Is one of these steps showing an error in the Query Builder when you select it? If so, exactly which step is giving you the error? If not, then you may be focusing on the wrong part of the issue and creating an XY Problem.
I can't immediately see any issues with the code snippet you've provided. However, I can see that your Required Rows columns both appear to be untyped, which could quite easily be causing the issue you describe, and/or preventing you from being able to identify it within the Query Builder. Make sure that both of these columns (and ALL other columns) are changed to an appropriate data type (probably Whole Number in this case) before you try to apply your changes to the model:
Again, if this doesn't fix the issue, or at least highlight it within the Query Builder, you'll need to provide ALL of your M code (anonymised) here. Without seeing everything that's happening in the query I just can't see where this issue may be occurring.
Pete