Welcome to the SAP HANA Academy. My name
is Bob and in this series of videos
we're going to be looking at how to
model analytic data within the SAP HANA
Extended Application Services Advanced
model. Which is also known as XS
Advanced. In this short video we're going
to be looking at using the replacing
data sources feature when you're
building calculation views. In the
previous few videos we've looked at
creating a range of calculation views. In
this video we're going to look at a
small feature which is how you can
easily replace data sources.
Let me demonstrate where you might use
it. So what we have is two views. One of
them is called simple and let me explain
how this view works. This view connects
to a facts table and a dimensions
table. Now if I have a look at the facts
table by doing a data preview of that
facts table. What you'll see is that the
data only goes up to 2015. So this is the
facts table that supplies data for this
calculation view. However, we have data in
our SAP HANA database all the way up to
2017. If I open up this other view that
we created in the previous video this is
the combination of two separate fact
tables. Again if I right click on the
facts table which is the same as what we
saw before what you'll see is that we
have data up till 2015. But what we did
in this calculation view is we Unioned
this data with another dataset from
another fact table which has two more
years of data. For 2016 and 2017.
Obviously this combination of Union data
is represented in this calculation view
here. We can see that if we perform a
data preview on the actual Union. So if I
look at my three different views here.
Again this simple view only has data up
to 2015. If I do a date of
preview of this what it shows is that,
for example, Chelsea have only won five
trophies. Whereas in 2016 they, 2017 they
want an additional trophy. Also we don't
see a team called Leicester. Which in
2016 won a single trophy. So what we're
going to want to do is kind of replace
the fact table which is measured, which
is indicated in this calculation view.
Now to demonstrate a good way of doing
this in order to preserve history, what
you can simply do with any of your views
is copy the view and then of course I
can paste it. Which means it will create
a view with a different name.
Obviously you must give it a different
name. So I'm going to call this one all
facts HDB calculation view and then I'll
click on OK. So of course what I'll do is
I'll make the changes to this all facts
HDB calculation view. So the changes are
quite simple. Again if I go and
maximize my active editor, all we need to
do is replace the fact table here with
the Union. If I right-click you have this
option here which is replaced with data
source. So again at the moment if I do a
data preview on facts we have data until
2015. If I right-click and do a replace
with data source we can go and select
that calculation view. So I'm going to
search for Union. This indicates that
it's of type calculation view. Again if I
expand the name we can see that it's the
Union calculation view and then I’ll
select it and click on next.
So what's going to happen is it's going
to tell me that inside this view we have
the following three columns. But the only
columns that we're actually going to
need are ID and season because they were
the only two columns used in our simple
calculation view. So all I need to do now
is select finish and what's happened is
of course, now if I go back and do a data
preview, we should see that we have the
data. If I sort descending from 2017/16
Then of course all the other
records. So the only thing we have to do
to this view is go to our semantics and
within view properties we just need to
make sure that the name here is
different so we don't get any
duplication. So I can do this by
selecting this pen here which will
enable us to edit. I'm going to simply
change simple to all facts. Like so. And
then we'll select this option which is
refactor. No other views will have been
impacted. So this can tell you if by
changing the name here it will impact
any of the views that you've got. A very
useful feature. So we'll select build and
of course you might want to change the
label as well to all facts like so. Just
to make sure that there's no conflict.
When you've done that of course now we
can click on save. I'll go back to my
active editor and of course what I'll do
now is I'll build this selected file.
There we can see the model built
successfully. So of course to test this
what I can do is I can right click on my
all facts calculation view and do a data
preview. So what we should see of course
is that Chelsea have had that additional
Trophy win, which was in 2017. But also we
should find another team, Leicester City
have a title win. So to demonstrate this
if I now do a data preview of our
original calculation view called simple.
You can see here Chelsea had five wins
where in the new version, we have six.
Additionally if I sort ascending by team
we now have Leicester City which have
won one championship and if I go back to
my old version and sort by team we don't
see Leicester City listed in this
calculation view. Of course this version
being the correct one. So that's a very
simple demonstration and how you can
simply copy HDB calculation views. How
you can easily replace data sources
within a calculation view. And lastly how
you can use a refactoring feature to
make sure that a view has no impact on
any other views. In the next video we're
going to be looking at another feature
which is ranking.