So before we were look at the aggregation functions, we will look at a quick tip.
We can always use in the beginning of a new project.
And with that tip, we can automatically create a date table that contains all the
dates of our model.
And that can be very useful.
So there are two options to do that.
The first option would be a little bit more menu.
And that would be with the calendar function.
We will have a look at this function afterwards.
But first, we will look at the other option that is to create that date table
automatically.
So what is this calendar auto function doing exactly this?
Function returns a table with only one column, and that column is called Date.
And this column contains a contiguous set of dates.
That means there are no missing dates.
So we have a range of dates that are automatically created based on the daytime our
model.
What does that mean?
So basically, what power be I will be doing is it will look at all of our data and
it will find the
earliest date in our model and it will also find the latest date in our model.
So it can calculate the full range of dates that are in between the earliest and
the latest dates.
It can also be possible that the earliest date is in one column.
And the latest date is in another column.
So that's totally possible.
Now, there's just one thing we have to keep in mind, and that has to do with here.
This fiscal year and month.
What does that mean?
That means that the date range will always create all the dates between the
beginning of the fiscal
year, up to the end of the fiscal year associated with our latest date.
So if the earliest date is 2nd of February 2000 seventeen, we will have a date
range that starts from
1st of January 2017, because that's the beginning of the fiscal year.
So we can set optional the parameter of the month where we want to have the fiscal
year to be started.
So if we don't use this parameter at all, it will be by default the number twelve.
That means that the end of the fiscal year will be December.
So that's what intuitively is usually the case.
And then we would have all dates between 1st of January and December.
Thirty first.
If we use a parameter year, for example, three, which represents March, all the
dates between March
1st, which will be the beginning and February 28, which will be the end of the
fiscal year, will
be returned.
Now, let's not make it too complicated and have a look at a real example in Pobby.
So let's jump to Power B. I to have a look.
So now we want to use this calendar auto function to do that.
What we will be doing is we just select one of our tables.
It doesn't matter which one because anyways we will not create a new column, but we
will create with
a DACS expression, a whole new table.
That is what we will be doing.
Therefore, we click on new table.
And then also this bar will open where we can specify a name of our new table so we
can just call this
date table.
And now we will just be using the calendar all to a function.
And we already have the auto suggest and we don't need, as I said, this parameter
physical year and
month, we can just leave that blank.
So let's have a look what the result of this table will be as we see.
We have now here our new table with only one column.
And that is the date column.
So let's have a look.
Which dates power.
B, I have produced.
So we will just move that up a little bit.
And we were look at this with a table.
So we click on table here.
And now what you see is that power be I automatically shows this as a hierarchy.
So because it is dates format automatically power B, I will use this data hierarchy
with year, quarter,
month and day.
I don't find that very comfortable right now.
Therefore, I would change that from the date hierarchy to the normal dates.
So now we see that we have all the dates starting from 1st of January 2017 until.
Thirty first of December 2020.
Now, as I said, keep in mind that this doesn't mean that the earliest state in our
data is 1st of
January, 2017.
It can be also that, for example, the earliest date is 5th of January.
But as the start of the fiscal year is 1st of January or the dates until 1st of
January will be created.
So if we have a look at our original data, then we can compare these states.
Let's use the original dates and also use a table so we can easily compare those.
So now we see that the first date in our data is actually 1st of May.
Any ways in our calculator table are the dates starting from the beginning of the
year is calculated.
So now let's have a look.
What is changing when we use here a parameter that is specifying the end of the
fiscal year?
So, for example, we can have a look if we insert here three, that means the year
will end at the
twenty eighth of February and start at the 1st of March.
So now let's have a look.
What is changing when we use this state?
So now we see the first date in our calculator table is not January 1st anymore,
but it's the 1st of
April.
And the last year.
And our model is now thirty first of March 2021, because that will be the end of
the year.
So just keep in mind that we can have different tables with different data columns
and power B..
I will now with this auto calendar function, look into all of these columns.
But what if we want to specify which column should be used to calculate our dates
table?
That is what we will be looking in the next lecture.
After that, I will also show you a little trick.
With that, you can easily create a lot of very interesting date features, such as
day of week or week
of the year and so on.
But first, let's have a look at the calendar.
Function.