Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a universal datatype correction function #1

Open
MattRudy opened this issue May 1, 2021 · 0 comments
Open

Add a universal datatype correction function #1

MattRudy opened this issue May 1, 2021 · 0 comments

Comments

@MattRudy
Copy link
Owner

MattRudy commented May 1, 2021

Problem

For columns with unknown or variable datatypes, it is hard to know the right type conversion method. Using the wrong conversion function in Power Query will cause errors on data load and prevent refreshes from succeeding.

i.e. if you want to compare dates, but don't know what format your input columns is contained in, you can't write a comparison without a risk of errors.

Text to Date is Date.FromText()
DateTime to Date is DateTime.Date()
Number (i.e. Unix/Epoch time) to Date requires significant parsing

Proposed Function

Types can be discovered using Value.Type(), and can be compared using the syntax '[Input] is text'.
A function like "OverrideType( [Input] , text , (errorVal) )' would take the value from the first argument and try to convert it to the type specified in the second argument. Cases where a translation could not be done would return the option value in the third parameter, such as null, a blank text string, or an error statement.

More information about Power Query M types can be found in the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant