From the course: Power BI Data Methods

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Adding data types in M code

Adding data types in M code - Power BI Tutorial

From the course: Power BI Data Methods

Adding data types in M code

- [Instructor] If we look at the data where we get the hourly weather data measurements for the weather for Santa Barbara, we notice in the applied steps that there's a lot of different steps going on here before we get to our final result. One of these is that we change type five times. We change it initially when we connect the Source step and it converts all the fields that we see here to text. It also converts the data type when we add columns, and again, when we add other columns, and two more times after that. So while we'll still see the Change Type step for the second step in the Applied Steps list, we can remove a lot of these additional steps to change the type by putting them directly in the column formula. To do so, we'll go into the step where we added a particular column. At the end of this function, before the final closing parentheses, let's set our data type for this new field. So day is going to be a number, so we'll set this to the Number.Type, and notice how it's…

Contents