Creating DAX functions with AI to remove duplicated code

How to leverage AI to refactor existing DAX code, remove duplicated parts, and centralize the common code in user-defined functions.