ciao friends in this video i want to
show you that you can use
the three task function in calculator
whenever you work with tables
let's start with our goal i have already
a measure here that computes the sales
amount
where the year is in 2007 or 2008.
this measure replaces the filter context
in the year with a new filter context
contained in 2007 and 2008
and you can see the result here despite
any year i put in the rows the total is
always the sum of 2007 and 2008
together your it is very unlikely that
you are going to use the measure with
the year
so we can get rid of the year from here
and instead we use for example the
product brand
now it's a bit more interesting i'm
looking at the by
the brand the full sales amount and the
sales in only two years
now my measure right now is using the
in function there is another way of
obtaining
the same goal which is very commonly
used by power bi
that is using the three test function
here under curved brackets i'm creating
a temporary table containing two numbers
if i just remove the eight year number
from the expression
and i only use the table as it is from a
synthetical point of view
it works but it doesn't filter anything
you see that
the total here now is the grand total
because this table is not
tied to any column in the model so the
engine has no clue on what to filter
with the two numbers 2007 and 2008.
there is a function three tas that takes
a table as its first argument
and tells the engine which column the
table needs to filter
so we can use a three task
and we are saying treat the table
containing 2007 or 2008
as if it were a date
year number column so now the engine
will know that 2007
and 2008 are indeed numbers that need to
be used
to filter the year number and using thin
syntax i have now the same behavior i
had before
there is a more about the tree test what
if
i'm not interested in two years i'm
interested in two months
in two different years for example i
might want to see
december 2007 and january 2008
now what i need is a table that contains
two columns
the year number and the month number
so the table will no longer contain only
these but it will be different it will
be 2007
12 and then 2008
1. what i'm creating here is a table
containing
two rows the first row has two columns
2007 and 12
the second column the second row has two
columns 2008 and one
and i need to tell the engine the first
column is a year
the second column is a month three tasks
can do that
i can tell the engine that the first
column the second argument of three does
is the type of the first column but i
can also say that the second column
is a date month number
let me format the code a bit better so
we can read it
i have the table then i have the type of
the first column
and the type of the second column
now it's clear that year number is 2007
month number is 2008
and if i hit enter now the numbers will
change
reflecting the sales in only two in only
two months
of two different years tritas is very
powerful you will find
a lot of different retards used as giza
if you inspect the queries generated by
power bi
because it's a very well optimized
function that proves extremely useful
enjoy dax
[Music]