Jesus said that doing the amazing and even the miraculous is not the basis of our salvation nor the essence of doing His will. It's possible that even those who invoke the name of Jesus and see God's miraculous power will end up outside of the kingdom. Why? Because they had no real relationship with God through authentic faith in His Son. In that sense, God doesn't know them despite all that they might do.