上QQ阅读APP看书,第一时间看更新
Format function – Month Year
As with any other language, you will find that there are usually multiple ways to do something. Now you are going to learn how to perform the calculation that we saw in the previous section using the FORMAT function. The FORMAT function allows you to take a number or date column and customize it in a number of ways. A side effect of the FORMAT function is that the resulting data type will be text. Let's perform the preceding calculation again, but this time using the FORMAT function.
Make sure you have the Date (order) table selected, and then click on Create a New Calculated Column by selecting New Column from the modeling ribbon. In the formula bar, write the following expression:
Month Year Format = FORMAT('Date (Order)'[Date], "MM-YYYY")
If you would like to take a full look at all the custom formatting options available using the FORMAT function, please take a look at https://tinyurl.com/pbiqs-format .